Skip to content

Commit 59681de

Browse files
committed
Polish documentation
1 parent f5d85f1 commit 59681de

16 files changed

+253
-98
lines changed

README.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Give a Star! :star:
44

5-
If you like or are using this project please give it a star or leave some feedback in the [discussions](https://github.com/NeilMacMullen/Textrude/discussions/categories/send-a-smile) section. Thanks!
5+
If you like or are using this project please give it a star or leave some feedback in the [discussions](https://github.com/NeilMacMullen/Textrude/discussions/categories/send-a-smile) section. A little feedback goes a long way - thanks!
66

77
## What is it?
88

@@ -28,19 +28,25 @@ Let's face it, there are any number of code-generation technologies you might co
2828

2929
Get pre-built binaries from the [Releases](https://github.com/NeilMacMullen/Textrude/releases) area or build yourself from source.
3030

31+
You may need to install [.Net 5.0](https://dotnet.microsoft.com/download/dotnet/5.0) if it is not already on your machine.
3132

32-
##Known issues...
33+
The binaries are provided in the form of a zip which includes single-file executables as well as example projects and library scripts.
34+
35+
36+
## Known issues...
3337
- YAML and CSV deserialisers will always attempt to force strings that look like numbers or booleans into that format rather than leaving them as strings. Most of the time this does not matter but please raise an issue if this causes particular problems
3438
- TextrudeInteractive does not warn when closing if project is dirty.
3539
- Textrude.exe is untested on Linux - please raise an issue if you run into problems
3640

3741
## Documentation
3842
- [Getting started with template generation](doc/gettingStarted.md)
39-
- Built in functions and helpers
40-
- Creating your own library of functions and templates
41-
- Using Textrude in a build system
42-
- advanced usage - multiple models and/or output files
43-
- use the exportInvocation
43+
- [Built in functions and helpers](doc/builtIns.md)
44+
- [Evironment variables and user-definitions](doc/environmentAndDefinitions.md)
45+
- [Multiple models and/or output files](doc/multiModel.md)
46+
47+
- [Creating and using library functions](doc/userlibrary.md)
48+
- [Using Textrude in a build system](doc/buildSystemIntegration.md)
49+
4450

4551
## Credits
4652

@@ -49,34 +55,32 @@ Textrude makes heavy use of the following components:
4955
- [CsvHelper](https://github.com/JoshClose/CsvHelper) for command-line parsing
5056
- [YamlDotNet](https://github.com/aaubry/YamlDotNet) for YAML deserialisation
5157
- [Json.Net](https://www.newtonsoft.com/json) for Json deserialisation
52-
53-
## Contributors guide
54-
Adding new model deserialisers...
55-
Architecture...
56-
57-
"Quick and dirty" - use jsonserialiser for new format types ... BUT can lose type information - particularly with numbers
58-
59-
file -> [Deserialiser] -> JObject -> ScriptObject
58+
- [Humanizr](https://github.com/Humanizr/Humanizer) for useful text-processing
59+
- [MaterialDesignToolkit](https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit), [MaterialDesignExtensions](https://spiegelp.github.io/MaterialDesignExtensions) and [Ookii Dialogs](https://github.com/augustoproiete/ookii-dialogs-wpf)to make the UI a bit less clunky
60+
6061

6162

62-
[Templatetext]
63-
[modelText]
6463

65-
[definionsText] ->
66-
[envs]
64+
## Help wanted
6765

68-
Extensions
69-
--binding custom dotnet functions- build your own version
66+
If you fancy making Textrude better, I'd be happy to have help! Some ideas for improvement...
7067

71-
Help wanted
72-
TextrudeInteractive has a UI only a developer could love and is very much a "scratch" project. Help make it better....
73-
Contribute to library methods
74-
Test on linux
75-
Documentation
68+
- UI
69+
- Change the current scratch code to a more formal MVVM architecture
70+
- Improve the text-edit boxes to show line numbers, syntax-hightlighting etc (maybe use AvalonEdit?)
71+
- Intellisense for template editing (we should be able to walk the models and suggest sensible dot completions)
72+
- Documentation and example projects
73+
- Library methods and helpers
74+
- More library functions for common tasks
75+
- Suggestions for 3rd party helper packages such as Humanizr
76+
- Distribution
77+
- Chocolately package?
78+
- General usage
79+
- Bug-reporting, real-world usability, Linux testing
7680

7781

7882
## What's with the name
7983
It's short for Text-extrude but if you can't stop seeing it as Text-Rude you are not alone.
8084

81-
It is unrelated to the rather cool (but apparently abandoned project) [Textruder](https://github.com/arrogantrobot/textruder) or to plastics company [Tex-Trude](http://www.tex-trude.com/)
85+
It is unrelated to both the rather cool (but apparently abandoned project) [Textruder](https://github.com/arrogantrobot/textruder) and the plastics company [Tex-Trude](http://www.tex-trude.com/)
8286

Tests/Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
1212
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
1313
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
14-
<PackageReference Include="coverlet.collector" Version="1.3.0">
14+
<PackageReference Include="coverlet.collector" Version="3.0.0">
1515
<PrivateAssets>all</PrivateAssets>
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
</PackageReference>

doc/buildSystemIntegration.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,56 @@
11
# Build system integration
22

3-
use textrude.exe --help to get a list of command
4-
textrude.exe help command to get detailed help
3+
TextrudeInteractive is useful for prototyping and developing models and templates but integration with a build-system requires use of the *textrude.exe* command-line tool. This version can do everythng that TextrudeInteractive does and has a few extra features:
4+
5+
## Getting help
6+
- use ```textrude.exe --help``` to get a list of command
7+
- use ```textrude.exe help``` *command* to get detailed help
8+
9+
## Basic rendering
10+
11+
```textrude.exe render --models model.yaml --template template.sbn --output out.txt```
12+
13+
If no *--output* is specified, the output will be written to stdout.
14+
15+
## Multiple input/output
16+
17+
```textrude.exe render --models "model0.Yaml" "model1.Json" "model2.Csv" --template "template.sbn" --output "out.txt" "out1.txt"```
18+
19+
## Definitions
20+
21+
```textrude.exe render --models model.yaml --template template.sbn --output out.txt --definitions "LANGUAGE=ENGLISH" "COUNTRY=UK"
22+
```
23+
24+
## Include-paths
25+
26+
```textrude.exe render --models model.yaml --template template.sbn --output out.txt --include "d:\work\slib" "d:\work\lib2"
27+
```
28+
## Dependency checking
29+
30+
By default, the render pass is always run. However, if the *--lazy* flag is supplied the Textrude will only render the output files if:
31+
- any of the output files are missing
32+
- any of the model files or the template file is newer than any of the output files.
33+
34+
Textrude is NOT able to perform dependency checking of library files include via the *include* directive.
35+
36+
## Return codes
37+
38+
0 - successful render or render skipped due to **lazy** flag
39+
1 - fault
40+
41+
## RenderFromFile
42+
43+
Sometimes it can be useful to be able to provide arguments from a file. The **renderFromFile** command allows the argument set to be passed in as a YAML or JSON structure.
44+
45+
```textrude.exe renderFromFile --arguments args.yaml```
46+
47+
You can easily generate example argument files by using the *project->export as invocation* option from TextrudeInteractive.
48+
49+
50+
51+
52+
53+
54+
55+
56+

doc/builtIns.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Built-in functions and helpers
2+
3+
4+
## Debug
5+
6+
*debug.dump* generates a representation of the object. For example:
7+
```
8+
{{debug.dump model}}
9+
```
10+
11+
## Humanizr
12+
13+
Textrude provides all the methods of the [Humanizr](https://github.com/Humanizr/Humanizer) library via the *humanizr* namespace. These are particularly useful for enforcing naming-conventions in generated code. For example
14+
15+
```
16+
The standard C naming for camel-cased strings looks like...
17+
18+
{{"CamelCasedFunctionName" | humanizr.underscore}}
19+
```
20+
21+
*Humanizr* has manyother useful functions - see the home page for more information.
22+
23+
See the *humanizr.txtproj* project in the examples folder for more examples
24+
25+
26+
## Misc
27+
28+
*misc.new_guid* generates a new GUID
29+
30+
See the *misc.txtproj* project in the examples folder for more examples
31+
32+
33+
## Libraries
34+
35+
### warnings
36+
The *autogenwarning* function provides a useful warning block at the beginning of the output.
37+
```
38+
{{include "lib/warnings.sbn}}
39+
{{autogenwarning}}
40+
```
41+
See the *includeExample* project in the examples folder.
42+
43+

doc/environmentAndDefinitions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Environment Variables and User-definitions
2+
3+
It's common when automating code-generation to want to pass in information that is not part of the model. Textrude *automatically* imports the environment variables from the current process and makes these available in the *env* namespace.
4+
5+
You can also supply *definitions* which appear in the *def* namespace. Definitions can be added from the "other->definitions" tab in TextrudeInteractive.
6+
7+
See the *enviromentAndDefinitions.texproj* project in the examples folder

doc/multiModel.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Using multiple models and/or multiple output files
2+
3+
It's sometimes useful to be able to combine information from multiple models and to render output to more than one file. For example, you might want to use a single template to render both a .h header file and a .cpp source file.
4+
5+
Textrude allows multiple models to be referenced as *model0*, *model1*, *model2* etc. There is no limit on the number of models that can be supplied although the UI of TextrudeInteractive current only supports 3.
6+
7+
By default, all output is rendered to the main output window but the SCRIBAN *capture* keyword can be used to redirect output to *output1*, *output2* etc. Currently only 10 output streams are supported.
8+
9+
The *multiInOut.texproj* project in the examples folder demonstrates this feature.

doc/userLibrary.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Creating a library of functions
2+
3+
Textrude supports reuse of code and templates via the SCRIBAN *include* function.
4+
You can set up additional include paths in the *other->include paths* section of the UI.
5+
6+
**IMPORTANT**
7+
You should use unix-style slashes for path separators
8+
9+
Example:
10+
11+
```
12+
{{include "customlib/myfunctions.sbn"}}
13+
```
14+
15+
16+

examples/enumtest.texproj

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"Description": "",
3+
"EngineInput": {
4+
"Definitions": [
5+
"LANGUAGE=ENGLISH",
6+
"COUNTRY=United Kingdom"
7+
],
8+
"IncludePaths": [],
9+
"Models": [
10+
{
11+
"Format": 2,
12+
"Text": ""
13+
},
14+
{
15+
"Format": 2,
16+
"Text": ""
17+
},
18+
{
19+
"Format": 2,
20+
"Text": ""
21+
}
22+
],
23+
"Template": "Access environment variables via the \u0027env\u0027 namespace:\r\n\r\n{{env.USERNAME}}\r\n\r\n\r\nAdd definitions from the other-\u003Edefintions tab and \r\naccess them via the \u0027def\u0027 namespace:\r\n\r\n{{def.LANGUAGE}} / {{def.COUNTRY}}\r\n\r\nYou can easily list all environment variables like this:\r\n\r\n{{debug.dump env}}\r\n"
24+
}
25+
}

examples/ex1_error_codes.texproj

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/humanizr.texproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"Description": "",
3+
"EngineInput": {
4+
"Definitions": [],
5+
"IncludePaths": [],
6+
"Models": [
7+
{
8+
"Format": 1,
9+
"Text": "text\r\na variable\r\nNameOfThing\r\nThe title of this book is\r\n\u0022 with spaces \u0022"
10+
},
11+
{
12+
"Format": 2,
13+
"Text": ""
14+
},
15+
{
16+
"Format": 2,
17+
"Text": ""
18+
}
19+
],
20+
"Template": "{{for v in model}}\r\n \r\n\u0027{{v.text}}\u0027\r\n PASCALIZE: \u0027{{v.text | humanizr.pascalize}}\u0027\r\n CAMEL: \u0027{{v.text | humanizr.camelize}}\u0027\r\n UNDERSCORE: \u0027{{v.text | humanizr.underscore}}\u0027\r\n TITLE: \u0027{{v.text | humanizr.titleize}}\u0027\r\n KEBAB: \u0027{{v.text | humanizr.kebaberize}}\u0027\r\n\r\n{{end}}"
21+
}
22+
}

examples/test.texproj renamed to examples/includeExample.texproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
"Text": ""
1818
}
1919
],
20-
"Template": ""
20+
"Template": "{{include \u0022lib/warnings.sbn\u0022}}\r\n\r\n{{autogenwarning}}"
2121
}
2222
}

examples/misc.texproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"Description": "",
3+
"EngineInput": {
4+
"Definitions": [],
5+
"IncludePaths": [],
6+
"Models": [
7+
{
8+
"Format": 0,
9+
"Text": "{\r\n\u0022top\u0022 : {\r\n \u0022number\u0022: 1,\r\n \u0022string\u0022: \u0022a string\u0022,\r\n \u0022array\u0022: [ 1,2,3,4]\r\n}\r\n}"
10+
},
11+
{
12+
"Format": 2,
13+
"Text": ""
14+
},
15+
{
16+
"Format": 2,
17+
"Text": ""
18+
}
19+
],
20+
"Template": "Here\u0027s a fresh guid...\r\n\r\n{{misc.new_guid}}\r\n\r\nHere\u0027s what your model looks like:\r\n\r\n{{debug.dump model}}\r\n"
21+
}
22+
}

examples/multiInOut.texproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"Description": "",
3+
"EngineInput": {
4+
"Definitions": [],
5+
"IncludePaths": [],
6+
"Models": [
7+
{
8+
"Format": 2,
9+
"Text": "name: yaml"
10+
},
11+
{
12+
"Format": 0,
13+
"Text": "{\r\n \u0022name\u0022:\u0022json\u0022\r\n}"
14+
},
15+
{
16+
"Format": 1,
17+
"Text": "name\r\ncsv"
18+
}
19+
],
20+
"Template": "Model 0 is {{model0.name}}\r\nModel 1 is {{model1.name}}\r\nModel 2 is {{model2[0].name}}\r\n\r\n\u0027model\u0027 is synonymous with \u0027model0\u0027...\r\n\r\n\u0027{{model.name}}\u0027 shoud be the same as \u0027{{model0.name}}\u0027\r\n\r\nTo write to another output, use the capture keyword...\r\n\r\n{{-capture output1}}\r\nYou won\u0027t see this in the output window. \r\nCheck the \u0022output1\u0022 window instead\r\n{{end}}\r\n\r\n\r\n{{-capture output2}}\r\nCapture scopes are temporary.\r\n{{end}}\r\n\r\nThat\u0027s all!\r\n"
21+
}
22+
}

0 commit comments

Comments
 (0)