使用Pydoc生成文档
来源:互联网 发布:java大数据方向学什么 编辑:程序博客网 时间:2024/05/01 03:44
Python中本身带有很多实用的工具,如pydoc。pydoc模块主要用来从Python模块中提取信息并生成文档。
使用方法
在Windows和Linux下的使用方法有些区别。
Windows
python -m pydoc <modulename>
如:
C:\>python -m pydoc module_test
NB:module_test是自定义的模块,不要添加文件后缀。
Linux
pydoc <modulename>
如:
$ pydoc module_test
pydoc参数
$ pydoc -hpydoc - the Python documentation toolpydoc <name> ... Show text documentation on something. <name> may be the name of a Python keyword, topic, function, module, or package, or a dotted reference to a class or function within a module or module in a package. If <name> contains a '/', it is used as the path to a Python source file to document. If name is 'keywords', 'topics', or 'modules', a listing of these things is displayed.pydoc -k <keyword> Search for a keyword in the synopsis lines of all available modules.pydoc -p <port> Start an HTTP server on the given port on the local machine.pydoc -w <name> ... Write out the HTML documentation for a module to a file in the current directory. If <name> contains a '/', it is treated as a filename; if it names a directory, documentation is written for all the contents.$
无参数 <name>
显示文档,<name>
可以是相查询的任何东西。如关键字、函数、模块、包等等。
C:\>python -m pydoc printHelp on built-in function print in module builtins:print(...) print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.C:\>python -m pydoc randomHelp on module random:NAME random - Random variable generators.DESCRIPTION integers -------- uniform within range sequences --------- pick random element pick random sample generate random permutation distributions on the real line: ------------------------------ uniform triangular normal (Gaussian) lognormal negative exponential gamma...
参数-k <keyword>
在可用模块中按关键字搜索。
C:\>python -m pydoc -k printcalendar - Calendar printing functionsemail.quoprimime - Quoted-printable content transfer encoding per RFCs 2045-2047.encodings.quopri_codec - Codec for quoted-printable encoding.json.tool - Command-line tool to validate and pretty-print JSONlib2to3.fixes.fix_print - Fixer for print.pprint - Support to pretty-print lists, tuples, & dictionaries recursively.pstats - Class for printing reports on profiled python code.quopri - Conversions to/from quoted-printable transport encoding as per RFC 1521.test.test_pprinttest.test_printtraceback - Extract, format and print information about Python stack traces.
参数-p <port>
在当前主机启用HTTP服务,使用指定的端口。
C:\>python -m pydoc -p 53241Server ready at http://localhost:53241/Server commands: [b]rowser, [q]uitserver> bserver>
如:
这时可以点击来跟踪链接进行查看相应的文档。
参数-w <name>
生成HTML文档。
首先编写一个模块,此外为class_test.py
:
"""A simple test."""if __name__ == "__main__": print("hello")
然后执行如下:
C:\>python -m pydoc -w class_testwrote class_test.html
此时在C盘根目录下生成了class_test.html
文件,就可以在浏览器中进行查看了。
更多请参考Python的pydoc模块。
0 0
- 使用Pydoc生成文档
- Python文档生成工具pydoc使用介绍
- Python文档生成工具pydoc使用介绍
- Python文档生成工具pydoc使用介绍
- Python文档生成工具pydoc
- Python文档生成工具pydoc
- Python文档生成工具pydoc
- Pydoc简单使用
- python文档生成工具pydoc在网页上查看的方法
- python查看帮助文档的命令--pydoc
- python学习-错误-pydoc不能使用
- 使用 doxygen 生成文档
- 使用doxmate生成文档
- 使用Appledoc生成文档
- 使用doxygen生成文档
- 使用DocFX生成文档
- Python学习笔记-pydoc的使用(待补充)
- 使用java生成pdf文档
- sting用法1
- 后台性能测试--性能测试方案设计
- [置顶] 我的Android进阶之旅------>Android中制作和查看自定义的Debug版本Android签名证书
- Linux系统脚本分析之rc.sysinit
- linux 终端的几个概念
- 使用Pydoc生成文档
- ZOJ 3897(模拟题)
- Spring4整合Hessian4(MavenWeb实例)
- Linux 空格和tab的替换
- js中 parseFloat() 函数
- Manacher算法求回文串兼leetcode 5Longest Palindromic Substring
- mybatis中 mapper.xml文件中,获取数组中指定的位置的数据
- 一、股市带动书市
- SSZipArchive 与 ZipArchive