Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1
Evaluate shell command or python code in sphinx and myst. maintainers:@Freed-Wu
License
sphinx-contrib/eval
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Evaluate shell command or python code in sphinx and myst.
Seehere.
docs/conf.py
extensions= ["sphinxcontrib.eval",]
Or
extensions= ["myst_parser","sphinxcontrib.eval",# must be after myst_parser]
For myst:
```{eval-sh}echo My OS is $OSTYPE.```
For rst:
..eval-sh:: echo My OS is $OSTYPE.Then build:
sphinx-build docs docs/_build/html
Result:
My OS is linux-gnu.NOTE: the current working directory depends on you. That is, if you runcd docs && sphinx-build . _build/html && cd -, CWD will bedocs, which isthe default setting ofhttps://readthedocs.org. So if your code structure islike
$tree --level 1 .├── docs├── scripts├── src└── tests
And you want to runscripts/*.sh, you needcd .. firstly fromdocs to. else you have to run../scripts/*.sh.
All of the following examples are myst. The corresponding examples of rst aresimilar. Click the hyperlinks of the titles and scripts to see the actualexamples.
Note: A more "sphinx" solution issphinxcontrib-autofile.
Before:
#API of Translate Shell```{eval-rst}.. automodule:: translate_shell :members:.. automodule:: translate_shell.__main__ :members:... (More)```
Now
#API of Translate Shell````{eval-rst}```{eval-sh}cd ..scripts/generate-api.md.pl src/*/*.py```````
Wherescripts/generate-api.md.plreplaces allsrc/translate_shell/XXX.pys to
..automodule::translate_shell.XXX:members:
Before:
#TODO-<https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/translators/stardict/__init__.py#L4> more stardicts.-<https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/translators/stardict/__init__.py#L5> Create different subclasses for different dict to get phonetic, explains-<https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/ui/repl.py#L33> make the last line gray like ptpython- ...
Now: (noticeeval-bash because readthedocs uses dash as their default$SHELL)
#TODO```{eval-bash}cd ..shopt -s globstarscripts/generate-todo.md.pl src/**/*.py```
Wherescripts/generate-todo.md.plsearches allTODOs in code then convert them to correct hyperlinks.
Note: A more "sphinx" solution issphinxcontrib-requirements-txt.
Before:
#Requirements##completionGenerate shell completion scripts.-[shtab](https://pypi.org/project/shtab)...
Now
#Requirements```{eval-sh}cd ..generate-requirements.md.pl```
Wherescripts/generate-requirements.md.plsearches allrequirements/*.txts andrequirements/completion.txt is:
#!/usr/bin/env -S pip install -r# Generate shell completion scripts.shtabSeedocument to know more.
About
Evaluate shell command or python code in sphinx and myst. maintainers:@Freed-Wu
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
- https://user-images.githubusercontent.com/32936898/199681341-1c5cfa61-4411-4b67-b268-7cd87c5867bb.png
- https://user-images.githubusercontent.com/32936898/199681363-1094a0be-85ca-49cf-a410-19b3d7965120.png
- https://user-images.githubusercontent.com/32936898/199681368-c34c2be7-e0d8-43ea-8c2c-d3e865da6aeb.png
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.