NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
460 stars 105 forks source link

Generating markdowns for installed python packages #40

Closed shaidams64 closed 6 years ago

shaidams64 commented 6 years ago

I was wondering if there's a way to create markdown files using the 'simple' command for modules in installed python packages. I'd like to create markdowns for my python packages from a different directory than the package itself but I haven't been successful so far. I get "module not found error" when I try to run the simple command from python, even though I'm importing the package. Here's an example:

import os; import sys
home = os.path.expanduser('~') 
sys.path.insert(1,home+'/cdwbLocal/data/workbench/modules/AnomalyDetection/')
import tsforecast
import pydocmd
from pydocmd import __main__ as docs

sys.argv = ["tsforecast", "simple"," tsforecast.load_store+ > doc3.md"]
docs.main()

do you have any suggestion? Thanks!

NiklasRosenstein commented 6 years ago

I haven't tried that myself yet but the last argument is definitely not what you think it might do. If you want to use > to write stdout to a file, you need your command be interpreted by a shell like bash.

Alternatively, you could just replace sys.stdout with the output file.

with open('doc3.md', 'w') as fp:
  sys.stdout = fp
  sys.argv = ["tsforecast", "simple"," tsforecast.load_store+"]
  docs.main()
NiklasRosenstein commented 6 years ago

I'll close this for now as this does not seem to be a bug with pydoc-markdown.

NiklasRosenstein commented 6 years ago

PS: Feel free to reopen/