推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
huntzhan
V2EX  ›  Python

zh-doclint,自动检测中文文档风格

  •  
  •   huntzhan ·
    huntzhan · Sep 6, 2016 · 3571 views
    This topic created in 3562 days ago, the information mentioned may be changed or developed.

    项目地址: https://github.com/huntzhan/zh-doclint

    目前仅支持 Markdown 格式的文档解析,文档规则( style guide )参考的是 写作规范和格式规范, DaoCloud 文档 的规范。

    7 replies    2016-09-08 06:11:41 +08:00
    laosb
        1
    laosb  
       Sep 6, 2016
    我在做一个类似的东西, https://github.com/laosb/halint

    我的设计上尽量做成可拓展的,规则使用也能自定义,不过现在 bug 比较多,打算用类似 AST 解析的方式重写。
    huntzhan
        2
    huntzhan  
    OP
       Sep 6, 2016
    @laosb 对任意文本建立 AST 应该很难吧,毕竟文本不像程序语言,没有良好定义。目前我的做法是分出段落与句子,然后按段落、句子上 regex 找非法的风格。
    laosb
        3
    laosb  
       Sep 7, 2016
    @huntzhan 我的想法并不是分解句子中每一个语言成分,对于这种简单的 lint 其实也没必要。这个 AST 的大致定义我写在 https://github.com/laosb/halint/blob/master/docs/ast-based-solution.md 了,还没开始写代码。
    huntzhan
        4
    huntzhan  
    OP
       Sep 7, 2016
    @laosb 懂了,挺不错的呀
    huntzhan
        5
    huntzhan  
    OP
       Sep 7, 2016
    @laosb 不过有几个点建议你也考虑一下: 1 、支持 markup ,特别是 Markdown 。 2 、包含各种 markup 格式的转换关系,包括解析后文本位置与原始 markup 文本位置的信息。这个信息在在做自动更正的时候比较有用。
    laosb
        6
    laosb  
       Sep 8, 2016
    @huntzhan 对,这就是代码里 fileParser 的作用,只不过现在只写了 plain text 的解析(按行直接拆开)。感觉如果切换到 AST 方案的话,要在 parser 处就部分解析为 AST 树(按段落、标题这些基本 markup 元素先拆开并矫正 position )。
    laosb
        7
    laosb  
       Sep 8, 2016
    @huntzhan 等我过两天休息找时间先重写 plain 的 parser 和 zh_cn 的 linter ,试试这个 AST 方案。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6164 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 03:03 · PVG 11:03 · LAX 20:03 · JFK 23:03
    ♥ Do have faith in what you're doing.