exemplify

Crates.ioexemplify
lib.rsexemplify
version0.1.6
sourcesrc
created_at2020-08-31 20:10:01.771936
updated_at2020-09-14 21:35:09.834068
descriptionTool for generating code examples from annotated source file directories
homepagehttps://github.com/JedimEmO/exemplify
repositoryhttps://github.com/JedimEmO/exemplify
max_upload_size
id283211
size19,103
Mathias Myrland (JedimEmO)

documentation

README

Exemplify - example code extractor for authors

Purpose

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.

Usage

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
Commit count: 35

cargo fmt