Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Evaluate shell command or python code in sphinx and myst. maintainers:@Freed-Wu

License

NotificationsYou must be signed in to change notification settings

sphinx-contrib/eval

Repository files navigation

pre-commit.ci statusgithub/workflowcodecovreadthedocs

github/downloadsgithub/downloads/latestgithub/issuesgithub/issues-closedgithub/issues-prgithub/issues-pr-closedgithub/discussionsgithub/milestonesgithub/forksgithub/starsgithub/watchersgithub/contributorsgithub/commit-activitygithub/last-commitgithub/release-date

github/licensegithub/languagesgithub/languages/topgithub/directory-file-countgithub/code-sizegithub/repo-sizegithub/v

pypi/statuspypi/vpypi/downloadspypi/formatpypi/implementationpypi/pyversions

Evaluate shell command or python code in sphinx and myst.

Install

Seehere.

Usage

Enable

docs/conf.py

extensions= ["sphinxcontrib.eval",]

Or

extensions= ["myst_parser","sphinxcontrib.eval",# must be after myst_parser]

Demonstration

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.

Advanced Usages

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.shtab

Seedocument to know more.

About

Evaluate shell command or python code in sphinx and myst. maintainers:@Freed-Wu

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2026 Movatter.jp