-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Please refer to my proof of concept repository, the code is runnable: https://github.com/Luashine/poc-macro-preprocessor
Short quote:
Motivation
I'm growing tired of having roughly equal (often exactly equal) text documentation blocks that must be included in multiple places across jassdoc.
This is an attempt to make a macro language/processor that's pleasant to use.
Goals:
- Make macro preprocessing optional for the writer.
- The entire text document must be as easily readable without the preprocessor active. This means changes must be applied to the file.
- Inline macro definitions
- Macros should be updatable at any point in time
- Easy to use and understand for non-programmers
Macro definition - @start block:
@start <name> <any text including multiline> end@
Macro reusage - @paste block:
@paste <name> <empty or previous macro value> end@
Example
Here it updates / replaces @paste directives.
Running command: 'diff 'macro-test/complex.txt' 'macro-test/complex.txt.out''
29c29
< @paste handle end@
---
> @paste handle It's a regular handle. end@
35c35,40
< @paste handlemulti end@
---
> @paste handlemulti It's a really
> really
> ordinary
>
> handle
> ok? end@@lep thoughts?
- Because continuing with manual copy-pasting will increase burden and inconsistencies later on.
- Maybe I don't know of some super-duper cool doc/macro tools, but this is simple and tailored to our needs
- The ingestion will need minor changes to how
@noteare processed. Only to drop the@start/@paste <name> end@in them.- however it is not a hard requirement, because plain-text is kept in place and readable.
- Lua or Bash? My goal was to minimize dependencies as well, so just a basic shell with coreutils would be enough.
- The Bash version may look scarier but is more robust, because it's already based on a state machine and can point out errors early.
- Lua needs an interpreter installed. Perl too. Although both may be preinstalled on some distros, especially Perl. No to both on Windows, while Bash can be used with coreutils out of the box with Cygwin/git for Windows
- I don't know awk to use in place of Bash 😛 and I never learned Perl either.
- Needs to be run manually to apply changes to old/new macros. Otherwise all text remains there
TODO: Finish and polish one of the scripts & change macro blocks to be "macro-new / macro-paste".
EDIT: The macro content is plain text by definition. Initially I intended macros to only be usable at the start of a line, end-tag must be at the end. It may result in a @note in body, but can contain just any regular text.