Skip to content

Commit 51908ff

Browse files
kianmengscrogson
andauthored
Misc doc changes (#353)
Besides other documentation changes, this commit ensures the generated HTML doc for HexDocs.pm will become the main source doc for this Elixir library which leverage on latest features of ExDoc. Co-authored-by: Sonny Scroggin <sonny@scrogg.in> Co-authored-by: Sonny Scroggin <sonny@scrogg.in>
1 parent 7443082 commit 51908ff

File tree

7 files changed

+110
-46
lines changed

7 files changed

+110
-46
lines changed

rustler_mix/.formatter.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Used by "mix format"
12
[
23
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
34
]

rustler_mix/.gitignore

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
/_build
2-
/cover
3-
/deps
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
417
erl_crash.dump
5-
*.ez
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
20+
*.ez
21+
22+
# Ignore package tarball (built via "mix hex.build").
23+
rustler-*.tar
24+
25+
26+
# Temporary files for e.g. tests
27+
/tmp

rustler_mix/README.md

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,51 @@
11
# Rustler
22

3-
This is the Mix package for [rustler](https://github.com/rusterlium/rustler), a library to write Erlang NIFs in
4-
safe Rust code. Here, we provide the basic functionality to use Rustler from Elixir:
3+
[![Module Version](https://img.shields.io/hexpm/v/rustler.svg)](https://hex.pm/packages/rustler)
4+
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/rustler/)
5+
[![Total Download](https://img.shields.io/hexpm/dt/rustler.svg)](https://hex.pm/packages/rustler)
6+
[![License](https://img.shields.io/hexpm/l/rustler.svg)](https://github.com/rusterlium/rustler/blob/master/LICENSE)
7+
[![Last Updated](https://img.shields.io/github/last-commit/rusterlium/rustler.svg)](https://github.com/rusterlium/rustler/commits/master)
58

6-
- A task to generate a new crate to write NIFs (`mix help rustler.new`)
7-
8-
See below for information on how to install this, which options are exposed through the configuration, and how t
9-
load a NIF.
9+
The Mix package for [rustler](https://github.com/rusterlium/rustler), a library to write Erlang Native Implemented Functions (NIFs) in [Rust](https://www.rust-lang.org/) programming language.
1010

1111
## Installation
1212

13-
This package is available on [`hex.pm`](https://hex.pm/packages/rustler). To install it, add it to your dependencies:
13+
This package is available on [Hex.pm](https://hex.pm/packages/rustler). To install it, add `:rustler` to your dependencies:
1414

1515
```elixir
1616
def deps do
17-
[{:rustler, "~> 0.22.0-rc.0"}]
17+
[
18+
{:rustler, "~> 0.22.0-rc.0"}
19+
]
1820
end
1921
```
2022

21-
Then,
23+
## Usage
24+
25+
1. Fetch all necessary dependencies:
26+
27+
```
28+
$ mix deps.get
29+
```
30+
2. Check your installation by showing help from the installed Mix task:
31+
32+
```
33+
$ mix help rustler.new
34+
```
35+
36+
3. Generate the boilerplate for a new Rustler project. Follow the instructions
37+
to configure your project:
38+
39+
```
40+
$ mix rustler.new
41+
```
2242
23-
1. Run `mix deps.get` to fetch the dependency.
24-
1. Run `mix rustler.new` and follow the instructions to generate the boilerplate for your NIF.
25-
1. Load the NIF in your program. [See below](#loading-the-nif).
43+
4. [Load the NIF in your program.](#loading-the-nif).
2644
2745
## Crate configuration
2846
2947
The Rust crate compilation can be controlled via Mix compile-time configuration in `config/config.exs`.
30-
See [configuration options](https://hexdocs.pm/rustler/Rustler.html#module-configuration-options) for more
31-
details.
48+
See [configuration options](https://hexdocs.pm/rustler/Rustler.html#module-configuration-options) for more details.
3249
3350
3451
## Loading the NIF
@@ -55,3 +72,16 @@ Note that `:crate` is the name in the `[lib]` section of your `Cargo.toml`. The
5572
`:crate` option is optional if your crate and `otp_app` use the same name.
5673

5774
See the `Rustler` module for more information.
75+
76+
## Copyright and License
77+
78+
Licensed under either of
79+
80+
- Apache License, Version 2.0, ([LICENSE-APACHE](../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
81+
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT)
82+
83+
at your option.
84+
85+
## Contribution
86+
87+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

rustler_mix/lib/mix/tasks/rustler.new.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Mix.Tasks.Rustler.New do
22
use Mix.Task
33
import Mix.Generator
44

5-
@shortdoc "Creates a new Rustler project"
5+
@shortdoc "Creates a new Rustler project."
66
@moduledoc """
77
Generates boilerplate for a new Rustler project.
88

rustler_mix/lib/rustler.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ defmodule Rustler do
44
55
When used, Rustler expects the `:otp_app` as option.
66
The `:otp_app` should point to the OTP application that
7-
the dynamic library can be loaded from. For example:
7+
the dynamic library can be loaded from.
8+
9+
For example:
810
911
defmodule MyNIF do
1012
use Rustler, otp_app: :my_nif
@@ -98,7 +100,7 @@ defmodule Rustler do
98100
@doc false
99101
def rustler_init do
100102
# Remove any old modules that may be loaded so we don't get
101-
# :error, {:upgrade, 'Upgrade not supported by this NIF library.'}}
103+
# {:error, {:upgrade, 'Upgrade not supported by this NIF library.'}}
102104
:code.purge(__MODULE__)
103105

104106
{otp_app, path} = @load_from

rustler_mix/mix.exs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,60 @@
11
defmodule Rustler.Mixfile do
22
use Mix.Project
33

4+
@source_url "https://github.com/rusterlium/rustler"
5+
@version "0.22.0-rc.0"
6+
47
def project do
58
[
69
app: :rustler,
7-
version: rustler_version(),
10+
name: "Rustler",
11+
version: @version,
812
elixir: "~> 1.6",
913
build_embedded: Mix.env() == :prod,
1014
start_permanent: Mix.env() == :prod,
11-
name: "Rustler",
12-
source_url: "https://github.com/rustlerium/rustler",
13-
homepage_url: "https://github.com/rusterlium/rustler",
1415
deps: deps(),
15-
docs: [
16-
main: "readme",
17-
extras: ["README.md", "../CHANGELOG.md"],
18-
source_url_pattern:
19-
"https://github.com/rusterlium/rustler/blob/rustler-#{rustler_version()}/rustler_mix/%{path}#L%{line}"
20-
],
2116
package: package(),
22-
description: description()
17+
docs: docs()
2318
]
2419
end
2520

26-
def rustler_version, do: "0.22.0-rc.0"
27-
2821
def application do
2922
[extra_applications: [:logger, :eex]]
3023
end
3124

3225
defp deps do
3326
[
3427
{:toml, "~> 0.5.2", runtime: false},
35-
{:ex_doc, "~> 0.21", only: :dev}
28+
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
3629
]
3730
end
3831

39-
defp description do
40-
"""
41-
Mix compiler and runtime helpers for Rustler.
42-
"""
43-
end
44-
4532
defp package do
4633
[
34+
description: "Mix compiler and runtime helpers for Rustler.",
4735
files: ["lib", "priv", "mix.exs", "README.md"],
4836
maintainers: ["hansihe"],
4937
licenses: ["MIT", "Apache-2.0"],
50-
links: %{"GitHub" => "https://github.com/rusterlium/rustler"}
38+
links: %{
39+
"Changelog" => "https://hexdocs.pm/rustler/changelog.html",
40+
"GitHub" => @source_url
41+
}
42+
]
43+
end
44+
45+
defp docs do
46+
[
47+
extras: [
48+
"../CHANGELOG.md",
49+
{:"../LICENSE-APACHE", [title: "License (Apache-2.0)"]},
50+
{:"../LICENSE-MIT", [title: "License (MIT)"]},
51+
"README.md"
52+
],
53+
main: "readme",
54+
homepage_url: @source_url,
55+
source_url: @source_url,
56+
source_url_pattern: "#{@source_url}/blob/rustler-#{@version}/rustler_mix/%{path}#L%{line}",
57+
formatters: ["html"]
5158
]
5259
end
5360
end

rustler_mix/mix.lock

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
%{
22
"earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"},
3-
"ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"},
4-
"makeup": {:hex, :makeup, "1.0.1", "82f332e461dc6c79dbd82fbe2a9c10d48ed07146f0a478286e590c83c52010b5", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49736fe5b66a08d8575bf5321d716bac5da20c8e6b97714fec2bcd6febcfa1f8"},
5-
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"},
6-
"nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"},
3+
"earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"},
4+
"ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"},
5+
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
6+
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
7+
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
8+
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
79
"toml": {:hex, :toml, "0.5.2", "e471388a8726d1ce51a6b32f864b8228a1eb8edc907a0edf2bb50eab9321b526", [:mix], [], "hexpm", "f1e3dabef71fb510d015fad18c0e05e7c57281001141504c6b69d94e99750a07"},
810
}

0 commit comments

Comments
 (0)