开发者

How to tell PyDoc to generate documentation to user defined directory

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 usin开发者_StackOverflowg python -m pydoc -w <MODULES_DIR> to generate documentation.

Is this possible and if it is, how?


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

mkdir -p doc
pydoc -w `find semlm -name '*.py'`
mv *.html doc

(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:

.PHONY: doc

doc:
    mkdir -p doc
    pydoc -w `find semlm -name '*.py'`
    mv *.html doc

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:

make doc

Perhaps there is a more elegant way, but this is the best I've found so far.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜