Crates.io | exemplify |
lib.rs | exemplify |
version | 0.1.6 |
source | src |
created_at | 2020-08-31 20:10:01.771936 |
updated_at | 2020-09-14 21:35:09.834068 |
description | Tool for generating code examples from annotated source file directories |
homepage | https://github.com/JedimEmO/exemplify |
repository | https://github.com/JedimEmO/exemplify |
max_upload_size | |
id | 283211 |
size | 19,103 |
I find it easier to keep example code green and alive if it is part of a compilable code base. This tool lets you annotate sections of your source code, and have generated includeable sample files with the highlighted parts.
First, annotate the example in your source file. You can combine multiple blocks, they will appear ordered by the optional part parameter.
// This chunk will be indented by 4 spaces relative to the other chunks in this example
//##exemplify-start##{name="name of the example" part=1 indentation=4 title="Some title" language="typescript"}
export class Foobar {
doSomething() {} // ##exemplify-callout##{value="Some callout"}
}
//##exemplify-end##
function doNotShowThis() {
// This will not be part of the example output file
}
//##exemplify-start##{name="name of the example" part=2}
new Foobar();
//##exemplify-end##
exemplify -s /path/to/example/code/root -o /path/to/output/folder -e "ts" --output-format=asciidoc
This should create the file name of the example.adoc in your output folder, with the following content:
.Some title
[source,typescript]
----
export class Foobar {
doSomething() {} <1> Some callout
}
new Foobar();
----
<1> Some callout