Skip to content

Commit

Permalink
[Tools] Add an example documentation generation flow
Browse files Browse the repository at this point in the history
  • Loading branch information
0x8000-0000 committed Apr 27, 2020
1 parent fdda7c4 commit 10ce3d3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
41 changes: 41 additions & 0 deletions doc/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,44 @@ and it does not support all SAMx functionality.

`generate_header` is part of the support for literate programing in SAMx, where we define enumerations and data
structures inside SAMx, then generate both end-user documentation and source code from the same model.

Makefile
--------

There is an experimental Makefile which implements a full documentation flow, tested on Ubuntu 18.04. The following packages
are required: xsltproc, fop, docbook-xsl-ns .

Here is an example session, assuming we have a document with included images which can all be processed by the included PlantUML processor:

```shell script
$ ls
samx_language.samx
$ make -f ~/tools/samxj-0.4.7/examples/Makefile samx_language.pdf
~/tools/samxj-0.4.7/bin/to_xml -b -i samx_language.samx -o samx_language.dbk -s ~/tools/samxj-0.4.7/schemas/docbook.rng.gz
Enable DocBook mode
XML output is well-formed
DocBook document validated using Jing
xsltproc -o samx_language.fo /usr/share/xml/docbook/stylesheet/docbook-xsl-ns/fo/docbook.xsl samx_language.dbk
Making portrait pages on USletter paper (8.5inx11in)
~/tools/samxj-0.4.7/bin/extract_code -i samx_language.samx -o .
Writing /tmp/test/ditaa-example.plantuml
java -jar ~/tools/samxj-0.4.7/lib/plantuml-1.2020.8.jar ditaa-example.plantuml
fop -pdf samx_language.pdf -fo samx_language.fo
[warning] /usr/bin/fop: JVM flavor 'sun' not understood
[WARN] FOUserAgent - Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400".
[WARN] FOUserAgent - Font "ZapfDingbats,normal,700" not found. Substituting with "ZapfDingbats,normal,400".
[INFO] FOUserAgent - Rendered page #1.
[INFO] FOUserAgent - Rendered page #2.
[INFO] FOUserAgent - Rendered page #3.
[INFO] FOUserAgent - Rendered page #4.
[INFO] FOUserAgent - Rendered page #5.
[INFO] FOUserAgent - Rendered page #6.
[INFO] FOUserAgent - Rendered page #7.
[INFO] FOUserAgent - Rendered page #8.
[INFO] FOUserAgent - Rendered page #9.
[INFO] FOUserAgent - Rendered page #10.
rm ditaa-example.plantuml samx_language.fo ditaa-example.png samx_language.dbk
```

This script is meant as an example and might be changed or moved in a subsequent release. The script outputs the exact
commands used so it can be used as a starting point for your own custom workflow.
3 changes: 3 additions & 0 deletions src/dist/bin/list_figures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

sed -n '/^ *```/s/ *```(\(\w*\)).*(\#\([-a-z.0-9]*\))/\2.\1/p;' $1
34 changes: 34 additions & 0 deletions src/dist/examples/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Example documentation flow
#
# (Tested on Ubuntu 18.04)
#
# Prerequisites:
# sudo apt install xsltproc fop docbook-xsl-ns

TOOLS_PATH=$(abspath $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..)
STYLESHEETS=/usr/share/xml/docbook/stylesheet/docbook-xsl-ns

SOURCE_FILE=$(MAKECMDGOALS:.pdf=.samx)
DEPENDENCIES=$(shell $(TOOLS_PATH)/bin/list_figures.sh $(SOURCE_FILE))

%.dbk: %.samx
$(TOOLS_PATH)/bin/to_xml -b -i $^ -o $@ -s $(TOOLS_PATH)/schemas/docbook.rng.gz

$(DEPENDENCIES): $(SOURCE_FILE)
$(TOOLS_PATH)/bin/extract_code -i $(SOURCE_FILE) -o .

.INTERMEDIATE: $(DEPENDENCIES)

%.png: %.plantuml
java -jar $(TOOLS_PATH)/lib/plantuml-1.2020.8.jar $^

%.fo: %.dbk
xsltproc -o $@ $(STYLESHEETS)/fo/docbook.xsl $<

%.pdf: %.fo $(DEPENDENCIES:.plantuml=.png)
fop -pdf $@ -fo $<

clean:
$(RM) *.fo *.img *.pdf *.plantuml

.PHONY: clean

0 comments on commit 10ce3d3

Please sign in to comment.