003 sphinx-prompt
源教程地址: https://pypi.org/project/sphinx-prompt/ .
Install
pip install sphinx-prompt
Initialize
In conf.py add extensions += ['sphinx-prompt'].
Syntax
A default prompt can be created using a prompt directive:
.. prompt::
<statements>
The prompt can be further customized in one of two ways:
Using positional arguments:
.. prompt:: [<language> [<prompts> [<modifiers>]]]
<statements>
Using options:
.. prompt::
:language: <language>
:prompts: <prompts>
:modifiers: <modifiers>
<statements>
While these constructs generate the same output, the positional arguments cannot be used if you want to use a prompt that contains spaces. This is a limitation of reStructuredText.
Positional arguments can be mixed with options if they don’t overlap (so if you pass prompts using options, you can only pass the language using positional arguments):
.. prompt:: bash
:prompts: (cool_project) $
python3 -m pip install --upgrade sphinx-prompt
Language
Supported language:
text(no pigments, default)bashbatchpowershellpythonscala
Prompt(s)
If modifier is auto, a comma-separated list of prompts to find in the statements.
Else the prompt to add on each statements, for Python and Bash language the end \ is supported.
Defaults to empty, except for the shell languages listed below:
bash-$batch-C:\>powershell-PS C:\>
Examples
See also
See: Sphinx-prompt .
.. prompt:: bash
cd <folder>
cp <src> \
<dst>
cd -
Results:
cd <folder>
cp <src> \
<dst>
cd -
.. prompt:: bash #
cd
cd -
Results:
cd
cd -
.. prompt:: bash $,# auto
$ sudo
# exit
$
Results:
sudo
exit
.. prompt:: bash $,(env)...$ auto
$ source env/bin/activate
(env)...$ deactivate
$
Results:
source env/bin/activate
deactivate
Run tests and prospector
python3 -m pip install --user --upgrade poetry
poetry install
poetry run pytest
poetry run prospector
The code should be formatted with black add isort.
Create new release
git tag <version>
git push origin <version>