如何告诉 PyDoc 生成文档到用户定义的目录
PyDoc 在生成模块文档时在当前目录中创建 HTML 文档。 我确实需要指定另一个目录,它将作为生成文档的占位符,而不是调用 PyDoc 的目录。
我正在使用 python -m pydoc -w
这可能吗?如果可能的话,如何实现?
PyDoc creates HTML documentation in current directory when generating documentation of modules.
I really need to specify another directory which will be a placeholder for generated documentation instead the directory from which PyDoc is called.
I am using python -m pydoc -w <MODULES_DIR>
to generate documentation.
Is this possible and if it is, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,并遇到了这个问题试图弄清楚。我也不知道该怎么做,所以这就是我的解决方案。我只是在当前目录中生成文档并将文件移动到我想要的位置,而不是尝试欺骗 pydoc 输出到特定位置。
在我的例子中,目标文件夹名为“doc”,源位于“semlm”目录下
(您应该能够根据需要自定义 pydoc 命令,但这对我有用)。
我不想每次都把这些都输入出来,所以我把它放在 Makefile 中。以下是摘录:
.PHONY: doc
是必需的,因为 Makefile 目标与顶级目录中的文件夹同名(即“doc”)。现在我可以通过运行以下命令将文档生成到 doc 文件夹中:也许有一种更优雅的方法,但这是迄今为止我发现的最好的方法。
I had the same issue and came across this question trying to figure it out. I couldn't figure out how to do it either, so this is my solution. Rather than try to trick pydoc to outputting to a specific location, I'm just generating the documentation in the current directory and moving the files to the location I want.
In my case, the target folder is named 'doc', and the source is located under the 'semlm' directory
(You should be able to customize the pydoc command as you wish, but this is what worked for me).
I didn't want to type this all out every time so I put it in a Makefile. Here is an excerpt:
The
.PHONY: doc
is needed because the Makefile target has the same name as a folder in the top level directory (i.e. 'doc'). Now I can generate documentation into the doc folder by running:Perhaps there is a more elegant way, but this is the best I've found so far.
pydoc -w ...
将模块的 HTML 文档写出到当前目录中的文件中
目录。如果包含“/”,则将其视为文件名;如果
它命名一个目录,为所有内容编写文档。
pydoc -w ...
Write out the HTML documentation for a module to a file in the current
directory. If contains a '/', it is treated as a filename; if
it names a directory, documentation is written for all the contents.