Skip to content

Commit 9796d62

Browse files
update readme with project status and usage (stellar#223)
1 parent a532c56 commit 9796d62

File tree

1 file changed

+51
-57
lines changed

1 file changed

+51
-57
lines changed

README.md

Lines changed: 51 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,24 @@
11
# Xdrgen
22

3-
[![Build Status](https://travis-ci.org/stellar/xdrgen.svg)](https://travis-ci.org/stellar/xdrgen)
4-
[![Code Climate](https://codeclimate.com/github/stellar/xdrgen/badges/gpa.svg)](https://codeclimate.com/github/stellar/xdrgen)
5-
63
`xdrgen` is a code generator that takes XDR IDL files (`.x` files) as specified
7-
in [RFC 4506](http://tools.ietf.org/html/rfc4506.html) and spits code out in
8-
various languages.
4+
in [RFC 4506](http://tools.ietf.org/html/rfc4506.html) and provides the AST to
5+
code generators. It can be used as a library with custom generators, or for
6+
legacy purposes as a CLI with any of the built-in legacy generators.
97

10-
`xdrgen` requires ruby 2.1 or later to run.
8+
`xdrgen` requires ruby 3.1 to 3.3 to run.
119

1210
## Status
1311

14-
Xdrgen is a very early project. Aside from the test fixtures in
15-
[spec/fixtures](spec/fixtures), the only .x files that have been thrown at it
16-
are the .x files used for the
17-
[stellar-core project](https://github.com/stellar/stellar-core).
18-
19-
Xdrgen presently supports these output languages: ruby, javacript, java,
20-
golang, elixir and Python:
21-
22-
- ruby: complete support
23-
- javascript: complete support
24-
- java: complete support
25-
- golang: currently using a fork of go-xdr, but has complete support
26-
- rust: support is experimental. Default arms and floats are not supported.
27-
- elixir: support is experimental as the SDK is in early development. Generated
28-
code requires [:exdr](https://github.com/revelrylabs/exdr) in your deps
29-
- C#: complete support
30-
- Python: complete support
31-
32-
Testing is _very_ sparse, but will improve over time.
33-
34-
## Usage as a binary
35-
36-
Xdrgen is a rubygem, compatible with ruby 2.1 or higher
37-
38-
$ gem install xdrgen
39-
40-
The command line:
41-
42-
`xdrgen [-o OUTPUT_DIR] [-l LANGUAGE] [-n NAMESPACE] [INPUT_FILES ...]`
43-
44-
### Language Specific Options
12+
Xdrgen is an early project but also relatively stable and major changes have
13+
not been made to the library for sometime.
4514

46-
### Rust
15+
Aside from the test fixtures in [spec/fixtures](spec/fixtures), the only .x
16+
files that have been tested with it are the .x files used for the [Stellar
17+
protocol](https://github.com/stellar/stellar-xdr).
4718

48-
`--rust-types-custom-str-impl`: Used to specify a comma-separated list of type names that should not have string conversion code generated as it will be provided by custom implementations provided by the developer using the generated code.
19+
If you're building a new code generator, the preferred way to provide a code
20+
generator to xdrgen is to use it as a library. See below for examples for how
21+
to do so.
4922

5023
## Usage as a library
5124

@@ -57,36 +30,57 @@ gem 'xdrgen'
5730

5831
And then execute:
5932

60-
$ bundle
33+
```
34+
$ bundle
35+
```
6136

6237
Example usage:
6338

6439
```ruby
6540
require 'xdrgen'
6641

67-
# create a compilation object, specifying your options
42+
class Generator < Xdrgen::Generators::Base
43+
def generate
44+
out = @output.open("#{@namespace}.rs")
45+
# Use @top to access the top of the AST.
46+
# Use @options to access any options passed via the compile.
47+
# Use out.puts to write code.
48+
end
49+
end
6850

69-
c = Xdrgen::Compilation.new(
51+
Xdrgen::Compilation.new(
7052
["MyProgram.x"],
7153
output_dir:"src/generated",
72-
language: :ruby,
54+
generator: Generator,
7355
namespace: "MyProgram::XDR",
74-
options: {
75-
rust_types_custom_str_impl: [],
76-
rust_types_custom_jsonschema_impl: [],
77-
},
78-
)
56+
options: { }, # any option your generator needs
57+
).compile
58+
```
7959

80-
# then run compile
60+
## Usage as a binary (legacy)
8161

82-
c.compile
62+
Xdrgen is a rubygem, compatible with ruby 2.1 or higher
8363

84-
```
64+
$ gem install xdrgen
65+
66+
The command line:
67+
68+
`xdrgen [-o OUTPUT_DIR] [-l LANGUAGE] [-n NAMESPACE] [INPUT_FILES ...]`
69+
70+
Xdrgen has support for built-in generators via the CLI's `-l` option, but they
71+
are not maintained, not tested, and are preserved for legacy usage.
72+
73+
- ruby: complete support
74+
- javascript: complete support
75+
- java: complete support
76+
- golang: currently using a fork of go-xdr, but has complete support
77+
- elixir: support is experimental as the SDK is in early development. Generated
78+
code requires [:exdr](https://github.com/revelrylabs/exdr) in your deps
79+
- C#: complete support
80+
- Python: complete support
8581

86-
## Contributing
82+
## Contributing new generators / languages
8783

88-
1. Fork it ( https://github.com/[my-github-username]/xdrgen/fork )
89-
2. Create your feature branch (`git checkout -b my-new-feature`)
90-
3. Commit your changes (`git commit -am 'Add some feature'`)
91-
4. Push to the branch (`git push origin my-new-feature`)
92-
5. Create a new Pull Request
84+
Instead of contributing new generators to this repository, use xdrgen as a
85+
library and maintain the generator independently where you can test and
86+
maintain it.

0 commit comments

Comments
 (0)