7

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?

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

2 Comments

Sorry, my mistake in syntax. I am using python -m pydoc -w <MODULES_DIR> but the generated document goes to current directory as I described. But I want that this document to be saved to some other directory. I don't know of any other switch to PyDoc which will produce the effect that I want.
Does the directory you specify exist? Do you append a / to the end of the directory name?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.