我刚开始使用Sphinx(sphinx-doc.org)来记录一个Python项目。到目前为止,它工作得很好,我能够记录和自动记录我的Python代码。
该项目还包含几个bash脚本。我想使用自动文档记录这些bash脚本。我没有找到特定于bash脚本的域。所以我猜想必须使用标准域?
如果可能的话,你会如何做到这一点?我需要如何配置index.rst文件以及如何在bash脚本中使用reStructuredText?
我刚开始使用Sphinx(sphinx-doc.org)来记录一个Python项目。到目前为止,它工作得很好,我能够记录和自动记录我的Python代码。
该项目还包含几个bash脚本。我想使用自动文档记录这些bash脚本。我没有找到特定于bash脚本的域。所以我猜想必须使用标准域?
如果可能的话,你会如何做到这一点?我需要如何配置index.rst文件以及如何在bash脚本中使用reStructuredText?
source_suffix
中使用.rst,但您可以在您网站的conf.py中更改它。请注意,我将bash文件命名为test.sh.rst以便提醒自己它是一个bash文件。只要您使用chmod +x
设置了mod,Linux就不会在意文件名是什么。.. _MyManual:
My Manual
===========================================
.. toctree::
:maxdepth: 2
:caption: Contents:
doc/doc
bash/test.sh
示例 test.sh.rst:
#!/bin/bash
: '
***********************
Example Bash
***********************
Using multi-line comment for larger comments.
And use hash # to proceed code so it shows nicely in sphinx. Note the double
:: at the end to give the proper formatting.
'
# Initial code::
mkdir tmp
# check_client::
check_client()
{
# determine if this is being run on a client that is using git folder
# check the parameter for the bash on CLI and if exist, use it
echo HERE in client "$1" and "$parameter_1"
if [[ "$parameter_1" = "" ]]; then
client_directory=/
else
client_directory=/git
fi
}
# other code::
parameter_1="$1"
check_client
echo the client is "$client_directory"
read -p "pause " answer