Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List generated files on --html #189

Closed
epogrebnyak opened this issue Apr 25, 2020 · 13 comments · Fixed by #197
Closed

List generated files on --html #189

epogrebnyak opened this issue Apr 25, 2020 · 13 comments · Fixed by #197
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@epogrebnyak
Copy link
Contributor

Starting to use pdoc3, great package, fast access to documentation.

A suggestion about README.md. The Usage section just mentions the inputs and no outputs:

Pdoc will accept a Python module file, package directory or an import path.

It would have helped me to learn from usage section that by default pdoc3 will save generated documentation to html/<package_name> folder. A user feels rather confused about not knowing what the program did.

Maybe can also add a message "Saved documentation to " as console ouput.

I can do a PR, if needed.

@kernc
Copy link
Member

kernc commented Apr 25, 2020

Maybe can also add a message "Saved documentation to " as console ouput.

Been thinking about this for a long while! A printed list of generated files certainly sounds practical. 👍

@kernc kernc added enhancement New feature or request help wanted Extra attention is needed labels Apr 25, 2020
@kernc kernc changed the title Describe program output in README.md List generated files on --html Apr 25, 2020
@kernc
Copy link
Member

kernc commented Apr 25, 2020

Maybe a note on --output-dir in help for --html? Feel free to revise.

@epogrebnyak
Copy link
Contributor Author

Maybe a note on --output-dir in help for --html? Feel free to revise.

That message helps, but I think in the documentation one needs to learn about the behaviour earlier to be able to run the first example quickly and be confident to know where is the output.

@epogrebnyak
Copy link
Contributor Author

Maybe can also add a message "Saved documentation to " as console ouput.

Been thinking about this for a long while! A printed list of generated files certainly sounds practical. 👍

Something in line of below?

Generated files:
d:\github\boo\docs\boo\columns.html
d:\github\boo\docs\boo\curl.html
d:\github\boo\docs\boo\errors.html
d:\github\boo\docs\boo\file.html
d:\github\boo\docs\boo\helper.html
d:\github\boo\docs\boo\index.html
d:\github\boo\docs\boo\main.html
d:\github\boo\docs\boo\okved.html
d:\github\boo\docs\boo\path.html
d:\github\boo\docs\boo\whatis.html
d:\github\boo\docs\boo\year.html

Would really help a new user! Let me consider how to implement for you with PR (print() is the easiest, but not the cleanest)

@kernc
Copy link
Member

kernc commented Apr 25, 2020

This further gives one the ability of quick review. 👍

And is useful in CLI sense. Look at the surrounding code, I think print() is used already.
Maybe redirect "Generated files:" to sys.stderr instead of stdout, this will make it universally composable (piped into xargs, etc.).

@epogrebnyak
Copy link
Contributor Author

Looks like we can achieve listing of files with a single print(f) in recursive_write_files, seems a bit too easy.

@kernc
Copy link
Member

kernc commented May 12, 2020

But that seems perfect! 😁

There is no more elaborate logging currently in place, and printing just filenames can indeed be further used in scripting.

@epogrebnyak
Copy link
Contributor Author

epogrebnyak commented May 12, 2020

@epogrebnyak
Copy link
Contributor Author

Couple observations - later in code we use sys.stdout.write, which is similar to print():

pdoc/pdoc/cli.py

Lines 497 to 500 in 5d15e61

else:
sys.stdout.write(module.text(**template_config))
# Two blank lines between two modules' texts
sys.stdout.write(os.linesep * (1 + 2 * int(module != modules[-1])))

Is there a special reason to use sys.stdout.write? Maybe change it to print() for consistency?
It took a while for me to htink over why this case is different from print and I could not think of a good answer.

@kernc
Copy link
Member

kernc commented May 12, 2020

print(..., end='\n') auto-appends a newline, file.write() writes literally.

I had to check myself. 😆

@epogrebnyak
Copy link
Contributor Author

Also a more general note - for Github the ideal example is pdoc --html -o docs mypackage, which produces documentation ready to be published for Github Pages. I think it is a strong usercase.

Currently pdoc --html -o docs mypackage will create documentation in docs/mypackage, not docs. This is a bit surprising, and to move documentation from docs/mypackage to docs, one needs an extra move command.

Two ideas:

  • change the behavior of -o switch (but that breaks your API)
  • add -O or some other switch that writes exactly to specified output_directory directory, not output_directory/package

@epogrebnyak
Copy link
Contributor Author

print(..., end='\n') auto-appends a newline, file.write() writes literally.

I had to check myself. 😆

That numbering of newlines looks like serious stuff: os.linesep * (1 + 2 * int(module != modules[-1])) :)

I understand now why you need write (), was not clear from start.

@kernc
Copy link
Member

kernc commented May 12, 2020

That numbering of newlines looks like serious stuff: os.linesep * (1 + 2 * int(module != modules[-1])) :)

Welcome to be as brief more clearly. 😛

Also a more general note - for Github the ideal example is pdoc --html -o docs mypackage, which produces documentation ready to be published for Github Pages. I think it is a strong usercase.

Discussed with some ideas and workarounds in #55.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

Successfully merging a pull request may close this issue.

2 participants