clindoc
1.0.0
ASP 文档框架,从用户到贡献者。
需要Python 3.10
要安装 Clindoc,您可以从 git 存储库克隆它:
git clone https://github.com/Owrel/clindoc.git
然后导航到 Clindoc 目录:
cd clindoc
最后,通过运行以下命令安装该软件包:
pip install .
要查看 Clindoc 的所有可用选项,您可以运行:
clindoc -h
Clindoc 允许您通过指定不同的选项来创建自定义文档。
例如,给定一个如下的文件夹结构:
sudoku
├── encoding
│ └── sudoku.lp
└── input.lp
您可以使用以下命令生成数独文件夹的文档(假设您位于 clindoc/examples/sudoku 目录中):
clindoc
指令是特殊注释,它们被标识为:
%@directive(param_1,...,param_n)
或带有可选描述
%@directive(param_1,...,param_n) -> Description
笔记
这是关联的正则表达式(带有命名组):
* @ * (?P< tag_name > [ a - z A - Z ] + ) * ( (?P< parameters > [ ^ - > ] * ) ) * ( - > * (?P< description > [ ^ \ n ] * ) ) ?
可以按部分拆分编码,为此,您可以添加指令section/1
,其中它将部分的名称作为参数。例如这样的:
%@section(Constraints) -> List all of the integrity constraints
:- . ..
:- . ..
可以给出用于更好地理解代码的变量的定义,例如var
指令将变量(大写)作为唯一参数
%@var(X) -> X refer the the x axis position
还可以为谓词给出定义,换句话说,谓词的含义,其中predicate
指令采用 2 个参数:签名(用作标识符)和默认变量。例如(从数独示例发出):
%@predicate(sudoku/3,sudoku(X,Y,V) ) -> The cell (`X`, `Y`) has value `V` with `0
还可以对特定行进行注释,以便添加对特定行正在执行的操作的说明,例如(从数独示例发出):
%- Can't repeat values per row
:- sudoku( X , Y , V ), sudoku( X '' , Y , V ), X ! = X '' .
以下是所有可用选项:
Clindoc - Generate documentation for ASP files
options:
-h, --help show this help message and exit
Global Clindoc parameters:
--project_name PROJECT_NAME, -p PROJECT_NAME
Name of the project
--src_dir SRC_DIR, -s SRC_DIR
Directory containing the LP files from which to generate the documentation
--description DESCRIPTION, --desc DESCRIPTION
Description of the project
--doc-dir DOC_DIR, -d DOC_DIR
The folder where the documentation in rst format will be generated. If not specified, it will default to [src-dir]/docs/)
--out-dir OUT_DIR, -b OUT_DIR
Directory where Sphinx will output the generated documentation (if not specified, defaults to [src-dir]/docs/build)
--builder BUILDER Sphinx output format parameter (refer to parameter builder sphinx. Can be any builder supported by Sphinx)
--clean (flag) remove [doc-dir] and [out-dir] before running. Please be sure that you saved any hand-made modification
--no-sphinx-build (flag,debug) skip Sphinx build
--no-rst-build (flag,debug) skip rst build section
--conf-path CONF_PATH
Path to a configuration file (json format). It can be created from the --dump-conf [path_to_conf] command. Any parameters entered in the command line will be ignored.
--dump-conf DUMP_CONF
Path of a file where the configuration will be dumped. The json file will include all of the configuration you've entered in the command line. It can be used later as default configuration using --path-conf [path_to_conf]
-v, --version Print the version and exit
User Documentation parameters:
--userdoc.exclude (flag) component will be excluded from the documentation
Contributor Documentation parameters:
--contributordoc.exclude
(flag) component will be excluded from the documentation
--contributordoc.group-by CONTRIBUTORDOC.GROUP_BY
How the contributor documentation will group the different elements. "section" or "type"
--contributordoc.hide-uncommented
(flag) hide non-commented or non-defined var, rules...
--contributordoc.hide-code
(flag) hide source code
Dependency graph parameters:
--dependencygraph.exclude
(flag) component will be excluded from the documentation
--dependencygraph.format DEPENDENCYGRAPH.FORMAT
Format of the graphs
Source files parameters:
--source.exclude (flag) component will be excluded from the documentation
--source.exclude-file [SOURCE.EXCLUDE_FILE ...]
source file(s) that will be excluded from source documentation section
KRR@UP - https://github.com/krr-up
通过导入 Clindoc 模块并为其提供所需的参数,还可以在 python 脚本中使用 Clindoc。
import os
from clindoc import Clindoc
print ( os . getcwd ()) # /path/to/clindoc
c = Clindoc ({ 'src_dir' : 'examples/mapf' })
c . build_documentation ()
字典中包含的参数与命令行中可用的选项相同。但是,- 字符必须替换为 _ 和 。应替换为子目录。例如,以下命令行:
clindoc --contributordoc.hide-code
将导致 python:
c = Clindoc ({ 'contributordoc' :
{ 'hide_code' : True }
})
c . build_documentation ()
这可以在创建文档时提供更大的灵活性和自动化,因为它可以集成到现有的 python 脚本和自动化流程中。
文件“test.py”包含可以使用的不同参数的示例。
波茨坦大学|波塔斯科解决方案