include library

master
Hasan al Rasyid 3 years ago
parent 0475e7f5db
commit d8d9132eaf
  1. 64
      manuscript.md

@ -459,28 +459,84 @@ let x = circle 10
## Running a subcommand ## Running a subcommand
Currently, subcommand only valid for Python script. 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 #!/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: 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 #!/usr/bin/env python3
print(""" print("""
| as | dd | | as | dd |
|----|----| |----|----|
| dd | 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 ## Subprocess delegation

Loading…
Cancel
Save