markdocs-使用markdown的python文档

markdocs的Python项目详细描述


从python源文件中提取标记注释和结构化输出 文档和自述文件

python文档

我很喜欢使用Markdown在 rustlang,因此我将在 Python。看一看 rustdochere an example 使用markdown comments为生锈的板条箱生成的文档站点。

使用^{tt1}提取信息$ https://docs.python.org/3.5/library/tokenize.html#examples

Markdown

工作原理

NOTE: this is just an early stage idea, not implemented yet! if you like please comment.

markdocs从所有.py文件和输出中提取文档 在一个组织良好的文档html站点中,可以使用 要公开和部署的mkdocs.org

markdocs /path/to/project

如果不想生成完整的文档,可以轻松生成 回购的自述文件

markdocs /path/project --readme README.md -k 'filter-oly-some-files-and-objects'

使用上面的aREADME.md生成,只包括筛选的 文件和对象文档,但也可以生成 为你的整个项目准备

该文件夹上的所有.py文件都将被解析为文档块 以下是以!开头的Python多行注释示例:

NOTE: if you don’t like mixing code and documentation, you can use a ^{tt5}$ to document ^{tt6}$ and the ^{tt7}$ should be located in the same folder or in ^{tt8}$ folder of the project. You can also write separated object files like in ^{tt9}$ which will be linked only to the ^{tt10}$ of ^{tt11}$.
"""!
# this is a documentation written in markdown
As it has only one `!` at the top, it is considered the module documentation
I can include module documentation along the file and will be merged in to the top level documentation
"""fromfooimportbar"""!!
# This is an object documentation, can be used for any object but most for functions and classes
It is defined before the object and not on the `__doc__` docstring, as markdocs does not conflicts with it.

## What are the advantages
- Markdown is easy to learn
- More people will contribute to documentation because they already know the format
- With simple commands like `markdocs /path --readme README.md` the readme for your repo is generated from markdocs
- Markdocs will generate the output for http://www.mkdocs.org/
- You can write bare `.md` files in a `mdocs` folder and they will be added to you documentation as well

[[params
  # X is the single param of this function
  x: int | default 0
  # The return is a string with the x interpolated.
]] result: str
"""defa_function(x=0):"""This regular docstring does not conflicts with the above markdoc"""returnf'Hello {x}'"""!!
# This is a class documentation
We can also define runnable and highlighted blocks of code.
```run
obj = MyClass()
```
"""classMyClass:"""the class docstring is not affected"""attr='foo'"""!!!
    # this is a method documentation
    [[params
       x: str
    ]]
    """defmethod(self,x):"""This is the regular docstring for method"""a=x"""!!!!
        ## Here we increase the nesting level
        Markdown is amazing!
        """definner_function(..):pass

正如您所看到的,还可以使用!!,实际上您可以使用 !!!!!要定义嵌套

解析器选项是:

网站输出格式

更多关于 https://gist.github.com/rochacbruno/1689c849f3ef54086772c410d77a82de

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java垂直解析txt文件   如何在从ovf部署vm时使用vi java api指定IP地址?   使用部分密钥进行java AES256解密   我无法接收RESTJava ws作为JSONObject发送到我的安卓应用程序的布尔值   java以下同步块的目的是什么?   java小部件在进入应用程序时停止更新   java如何在Okhttp中使用Socks5代理来启动http请求   java Android多资源库项目   java使用条形码4J创建gif条形码   java Play测试数据持久性问题使用GET时,发布的数据不可用   java Jnlp在证书中给出错误   java将我的exist服务器连接到GCM   AChartEngine中XAxis标题和XAxis标签之间的java边距   java BLOb:无法读取所有数据,但只有很少的kb   java Android WebView未加载Instagram授权   JAVAutil。日志记录可以指定一个java。util。通过D选项或不需要更改代码的某种方式创建日志格式化程序?   windows如何在Inno安装程序的路径中查找应用程序(Java)   java如何使用Jgit API调用“git checkout m”?   客户端Java服务器:通过广播在讲师和学生之间进行会议