Skip to content

Commit 2ded668

Browse files
Add contributing documentation for stefc (#269)
1 parent 5c50753 commit 2ded668

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and fast serialization. See some
1212
- [go/grpc](./go/grpc): STEF/gRPC protocol implementation in Go.
1313
- [go/otel](./go/otel): Otel/STEF protocol schema and generated code in Go.
1414
- [go/pdata](./go/pdata): Collector pdata <-> Otel/STEF converters.
15+
- [java/src/main/java/net/stef](./java/src/main/java/net/stef): STEF supporting libraries for Java.
1516
- [stef-spec](./stef-spec): STEF Specification and Protobuf definitions.
1617
- [stefc](./stefc): STEF Compiler to generate serializers from STEF schema.
1718

java/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,11 @@ This directory contains Java implementation of STEF.
99

1010
# Building and Running Tests
1111

12-
- To build and run all tests do `./gradlew build`.
13-
- To generate the JMH performance benchmarks run `./gradlew jmh`.
12+
To build and run all tests do `./gradlew build`.
13+
14+
To run tests on variety of test schemas first run `cd ../stefc && make test`.
15+
This will generate serializers/deserializers for test schemas in Java and will place
16+
them in [src/test/java/com/example/gentest](./src/test/java/com/example/gentest) directory.
17+
Then run `./gradlew test` to test generated code.
18+
19+
To generate the JMH performance benchmarks run `./gradlew jmh`.

java/src/main/java/net/stef/README.md

Whitespace-only changes.

stefc/README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
1-
# STEF Generator
1+
# STEF Compiler
2+
3+
stefc is a command-line compiler and code generator that takes STEF schema files as
4+
input and generates type-safe serialization and deserialization code for multiple
5+
programming languages. For usage instructions, please refer to
6+
[STEFC documentation](https://www.stefdata.net/stefc.html).
7+
8+
## Design
9+
10+
stefc is implemented in Go and uses Go [text/template](https://pkg.go.dev/text/template)
11+
for code generation. There is a set of templates for each target language:
12+
13+
- [Templates for Go](./templates/go)
14+
- [Templates for Java](./templates/java)
15+
16+
stefc parses the input STEF schema file, then generates code by applying the parsed schema
17+
to the appropriate templates for the specified target language. See generator
18+
implementation in [generator](./generator) package.
19+
20+
Template files contain templated code to represent in-memory and to serialize and
21+
deserialize supported types (structs, oneofs, enums, arrays, maps).
22+
23+
## Building and Testing
24+
25+
Pre-requisites:
26+
27+
- make
28+
- Go 1.24 or newer
29+
30+
To build stefc, run `make build`. To run tests, use `make test`.
31+
32+
[generator/testdata](./generator/testdata) contains STEF schema files that are used in
33+
unit tests for the code generator. For each of these schema files, a test is run that
34+
generates Go and Java code from the schema, then runs generated tests that verify
35+
correctness of serialization and deserialization. Generated tests use randomized input
36+
from an initial seed of a random number generator. "seeds" directory contains recorded
37+
seeds for each test case that previously resulted in detected bugs. These seeds are used
38+
to avoid regressions.
39+
40+
If you make any changes to template files or to the generator code, rerun `make all`
41+
to ensure that all generated code is up to date and all tests are run.
42+
43+
stefc is also used for generating code in [examples](../examples) directory and
44+
in [otel](../go/otel) directory.

0 commit comments

Comments
 (0)