A shell script documentation system
一个shell脚本文档系统
__
▓#.▓▒
▓▓▓▓▒▒▒▒
▓▓▓
___/▓▓▓▓▓▓▓▒▒ ▏
< ▒▒ ▏
\ shelldoc ▒ /
~~~~~~~~~~~~~~~~~~~~~~~
The shelldoc system provides a simple way to embed user documentation into Unix shell scripts. shelldoc is a Bourne shell compatible script that searches for specially formatted comments in text input (usually a Unix script file) on STDIN which are then emitted as the user documentation in reStructuredText format on STDOUT. All other code and standard comments within the source text are quietly ignored.shelldoc系统提供了一种将用户文档嵌入Unix shell脚本的简单方法。shelldoc是一个Bourne shell兼容的脚本,它在STDIN上搜索文本输入(通常是Unix脚本文件)中特殊格式的注释,然后在STDOUT上以reStructuredText格式作为用户文档发出。源文本中的所有其他代码和标准注释都将被忽略。
reStructuredText is a very lightweight form of markup that does not interfere with the human readability of the text. The Docutils project defnes the standard and provides filters to convert reStructuredText into html, latex (and on to PDF), and man format. Thus the same shelldoc documentation comments within a script can be extracted into a text file, a web page, a man page or a PDF file, covering all the main forms of electronic documentation.reStructuredText是一种非常轻量级的标记形式,它不会影响文本的可读性。Docutils项目定义了标准,并提供了将reStructuredText转换为html、latex(以及PDF)和man格式的过滤器。因此,脚本中相同的shelldoc文档注释可以提取到文本文件、网页、手册页或PDF文件中,涵盖所有主要形式的电子文档。
Other text documentation, such as README files, licenses and version histories can also be included in the source text as numbered appendices. This makes it possible to maintain and distrubute a single script file that contains all of its necessary user documentation.其他文本文档,如README文件、许可证和版本历史记录也可以作为编号的附录包含在源文本中。这使得维护和分发包含所有必要用户文档的单个脚本文件成为可能。
The shelldoc script file serves as full documentation, a "feature-complete" test of the shelldoc system and an example for usage of all features of the shelldoc syntax.shelldoc脚本文件作为完整的文档,是对shelldoc系统的一个“功能完整”的测试,也是一个使用shelldoc语法所有功能的示例。
Download the shelldoc script file and save it somewhere in your $PATH, for example:下载shelldoc脚本文件并将其保存在$PATH中,例如:
~/bin/shelldoc
then make sure that it is executable:然后确保它是可执行的:
chmod +x ~/bin/shelldoc
Then you can try the following commands to see how it works:然后你可以尝试下面的命令看看它是如何工作的:
# print shelldoc's documentation to the terminal:
shelldoc < shelldoc
# or view it as a manual page (requires Docutils):
shelldoc < shelldoc | rst2man | man -l -
# or save it as a web page (requires Docutils):
shelldoc < shelldoc | rst2html | shelldoc.html
# or save it as a plain text file:
shelldoc < shelldoc > shelldoc.txt
# view the licence:
shelldoc -a 1 < shelldoc
# save the version history:
shelldoc -a 2 < shelldoc > versions.txt
# save this readme file:
shelldoc -a 3 < shelldoc > README.md
# add a documentation template to another script:
shelldoc -t < myscript > mydocumentedscript
# strip documentation from a script:
shelldoc -s < mydocumentedscript > mycleanscript
The mascot of shelldoc is a Shelduck -- Tadorna tadorna (Linnaeus, 1758) -- a large and colourful duck found mainly in coastal areas across Eurasia. It nests in rabbit burrows or tree holes. The hatchlings leave the nest quickly and are led by their parents to nurseries on ponds lakes or rivers, often up to a mile away. There, they join other broods to form crêches of up to 100 young birds. A small number of adults stay behind to watch over these youngsters, while most of the parents fly off to join huge moulting flocks in coastal waters. These moulting flocks can contain many thousands of birds and are a spectacular sight on the Dutch and German Northern coast, as well as smaller gatherings on the Wash in England and the Firth of Forth in Scotland.shelldoc的吉祥物是一只鸭——Tadorna Tadorna (Linnaeus, 1758)——一种主要分布在欧亚大陆沿海地区的大型彩色鸭子。它在兔子洞或树洞里筑巢。幼鸟很快离开巢穴,由它们的父母带到一英里外的池塘、湖泊或河流上的托儿所。在那里,它们和其他幼鸟一起组成了crêches,有多达100只幼鸟。一小部分成年企鹅留下来照看这些幼崽,而大多数父母则飞到沿海水域加入庞大的换毛群。这些换羽的鸟群可以容纳成千上万只鸟,是荷兰和德国北部海岸的壮观景象,也是英格兰沃什和苏格兰福斯湾的小型聚会。
https://github.com/scripsi/shelldoc
评论
发表评论