You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Besides other changes, this commit ensures the generated HTML doc for
hexdocs.pm will become the main source doc for this Elixir library which
leverage ExDoc features.
Co-authored-by: Andrea Leopardi <an.leopardi@gmail.com>
A pure Elixir implementation of [Google Protobuf](https://developers.google.com/protocol-buffers/)
5
+
A pure Elixir implementation of [Google Protobuf](https://developers.google.com/protocol-buffers/).
7
6
8
7
## Why this instead of exprotobuf(gpb)?
9
8
10
9
It has some must-have and other cool features like:
11
10
12
11
1. A protoc [plugin](https://developers.google.com/protocol-buffers/docs/cpptutorial#compiling-your-protocol-buffers) to generate Elixir code just like what other official libs do, which is powerful and reliable.
13
-
2. Generate **simple and explicit** code with the power of Macro. (see[test/support/test_msg.ex](https://github.com/tony612/protobuf-elixir/blob/master/test/support/test_msg.ex))
12
+
2. Generate **simple and explicit** code with the power of Macro. See[test/support/test_msg.ex](https://github.com/tony612/protobuf-elixir/blob/master/test/support/test_msg.ex).
14
13
3. Plugins support. Only [grpc](https://github.com/tony612/grpc-elixir) is supported now.
15
14
4. Use **structs** for messages instead of Erlang records.
16
15
5. Support Typespec in generated code.
17
16
18
17
## Installation
19
18
20
-
The package can be installed by adding `protobuf` to your list of dependencies in `mix.exs`:
19
+
The package can be installed by adding `:protobuf` to your list of dependencies in `mix.exs`:
21
20
22
21
```elixir
23
22
defdepsdo
@@ -51,40 +50,47 @@ end
51
50
52
51
### Generate Elixir code
53
52
54
-
1. Install `protoc`(cpp) [here](https://github.com/google/protobuf/blob/master/src/README.md) or `brew install protobuf` on MacOS.
55
-
2. Install protoc plugin `protoc-gen-elixir` for Elixir . NOTE: You have to make sure `protoc-gen-elixir`(this name is important) is in your PATH.
56
-
```
57
-
$ mix escript.install hex protobuf
58
-
```
59
-
3. Generate Elixir code using protoc
60
-
```
61
-
$ protoc --elixir_out=./lib helloworld.proto
62
-
```
63
-
4. Files `helloworld.pb.ex` will be generated, like:
53
+
1. Install `protoc`(cpp) [here](https://github.com/google/protobuf/blob/master/src/README.md) or
54
+
`brew install protobuf` on MacOS.
64
55
65
-
```elixir
66
-
defmoduleHelloworld.HelloRequestdo
67
-
useProtobuf, syntax::proto3
56
+
2. Install protoc plugin `protoc-gen-elixir` for Elixir . NOTE: You have to
57
+
make sure `protoc-gen-elixir`(this name is important) is in your PATH.
68
58
69
-
@type t :: %__MODULE__{
70
-
name:String.t
71
-
}
72
-
defstruct [:name]
59
+
```bash
60
+
$ mix escript.install hex protobuf
61
+
```
73
62
74
-
field :name, 1, type::string
75
-
end
63
+
3. Generate Elixir code using protoc
76
64
77
-
defmoduleHelloworld.HelloReplydo
78
-
useProtobuf, syntax::proto3
65
+
```bash
66
+
$ protoc --elixir_out=./lib helloworld.proto
67
+
```
79
68
80
-
@type t :: %__MODULE__{
81
-
message:String.t
82
-
}
83
-
defstruct [:message]
69
+
4. Files `helloworld.pb.ex` will be generated, like:
0 commit comments