Snyp是一个命令行实用程序,它简化了在Markdown中创建基于文本的文档和编程教程的过程。
snyp的Python项目详细描述
Snyp公司
Snyp是一个命令行实用程序,它简化了在Markdown中创建基于文本的文档和编程教程的过程。在
Snyp从源文件中提取指定的代码段,对其进行格式化以在Github风格的Markdown中启用语法高亮显示,并在其前缀添加一个注释,精确地指定代码段从何处提取,即:
```python
# snippet from example.py lines 1-2
print('Hey there!')
print('This is an example')
```
将呈现如下:
^{pr2}$安装:
pip install snyp
用法:snyp --help
Usage: snyp.py [OPTIONS][LINES]... Use this tool to extract code snippets from a source file (src) and append them to a markdown file (dest) with proper Github Flavored Markdown formatting. You can use 0, 1 or 2'lines' arguments: With 0 arguments, the entire source file will be extracted With 1 argument, the entire source file starting at lines[0] will be extracted With 2 arguments, lines lines[0] to lines[1](inclusively) will be extracted from the source file Use snip --config to view and update the configuration Options: -s, --src TEXT The source file from which to extract the code snippet -d, --dest TEXT The destination file to which to append the formatted snippet. "-"for stdout -l, --lang TEXT The language specific formatting to be applied to the code snippet -c, --config Edit the configuration, i.e. to change defaults, add languages, etc. --help Show this message and exit.
配置snyp --config
上面的命令将在默认编辑器中打开Snyp的配置文件。这是查看和更新配置的最简单方法。在
节[默认值]
# snippet from snyp.ini lines 1-5 [default]default=pythonsrc=snyp.pydest=README.md
- default:未提供-l,--lang时要使用的默认语言配置文件
- src:如果未提供-s,--src,则默认源文件的相对路径
- dest:如果未提供-d,--dest,则默认目标文件的相对路径
语言部分:[python]等
# snippet from snyp.ini lines 16-19 [html]lang=htmlcommentStart=<!--commentEnd=-->
- 语言的名称。用于确定语法突出显示的前缀
- commentStart:注释如何在lang中开始
- commentEnd(可选):注释如何以lang
- 项目
标签: