From d8d9132eaf46e8af21e6fe370e311953cf758ac3 Mon Sep 17 00:00:00 2001 From: Hasan al Rasyid Date: Fri, 18 Mar 2022 23:12:50 +0900 Subject: [PATCH] include library --- manuscript.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/manuscript.md b/manuscript.md index 54f9567..2c6f52b 100644 --- a/manuscript.md +++ b/manuscript.md @@ -459,28 +459,84 @@ let x = circle 10 ## Running a subcommand Currently, subcommand only valid for Python script. +There are two possible class available for this subcommand. +`.md` would output a text document that would be translated to a markdown by pubsEngine. +In this scenario, the script should output a valid markdown document to the stdout. +We are expecting the usage of `.md` to produce some sort of table, or a dynamic paragraph. ``` -~~~{.script .py .md} +~~~{.script .py .md #tbl:py caption="this is a table script"} #!/usr/bin/env python3 -echo "this is the real me" +print(""" +| as | dd | +|----|----| +| dd | dd | +Table: this is output of a python script +""") ~~~ ``` The above snipplet would give us output: -~~~{.script .py .md} +~~~{.script .py .md #tbl:py caption="this is a table script"} #!/usr/bin/env python3 print(""" | as | dd | |----|----| | dd | dd | -Table: we are +Table: this is output of a python script """) ~~~ +On the otherhand, `.img` will produce an image in the document. +This scenario expects the script will run an IO and must create an image file inside directory `_build/auto` by the filename designated by `out`. +The image at Figure \ref{fig:py} can be produced using: + +``` +~~~{.script .py .img #fig:py caption="this is a new image from script" width=400 height=300 out=pyImage} +#!/usr/bin/env python3 + +print("image new image") +~~~ +``` + +~~~{.script .py .img #fig:py caption="this is a new image from script" width=400 height=300 out=pyImage} +#!/usr/bin/env python3 + +print("image new image") +~~~ + +To make this document can stands on its own and to remove repetitive codes, we can also include a python library inside `_build/lib` directory. +All script above, will include all files mentioned inside `_build/lib`. +Furthermore, the `_build/lib` will be populated by CodeBlock with `.lib` class. +This is an example of the block: + +``` +~~~{.script .py .lib #fig:py} +#!/usr/bin/env python3 + +print("this is new block") +~~~ +``` + +We can choose the representation of this block inside the pdf output by providing `description` variable. +When there is no `description`, then this `lib` CodeBlock will be considered as a *hidden library*, it will be still included inside every script, but it will be never mentioned inside the pdf result. + + +~~~{.script .py .lib name="libPy1"} +#!/usr/bin/env python3 + +def f(x): + return x*x + 2*x + 3 + +description=""" +This is the description of this library that will be inserted into the pdf output. +We can use any valid markdown syntax. +""" +~~~ + ## Subprocess delegation