Add show_source flag to allow for hiding of source code in output#283
Add show_source flag to allow for hiding of source code in output#283jbrunton96 wants to merge 1 commit intomitmproxy:mainfrom jbrunton96:hide_source
Conversation
|
Thanks for the PR! The code changes look excellent, but I'm not sure yet if this is a direction we want to go towards. Long story short, let me think about this for a few days. We could also add a short section to the docs with a small example on how to override the view source macro (https://github.com/mitmproxy/pdoc/blob/main/examples/custom-template/module.html.jinja2 already has one). Then again, maybe we do want to add a "render options" argument group and put more stuff there. |
|
I appreciate the concern over the commandline interface ballooning into something ridiculous but I wonder if there's a middle-ground to be reached here. I've not thought very much about whether this is actually a sensible implementation or even if it is something If you use def configure(*,
template_directory=None, docformat=None, edit_url_map=None, show_source=True, # Values that have commandline options
**kwargs # For config options that either the user wants to use in the default templates or add to their own templates
):
...
env.globals["edit_url_map"] = edit_url_map or {}
env.globals["docformat"] = docformat
env.globals["show_source"] = show_source
for key, value in kwargs.items():
env.globals[key] = valueWith this approach, the message could be:
With this tiered approach, the module can support: users who just want to generate docs from some existing Python they've found lying around; users who wrote a Python tool with docs (and are therefore comfortable with writing pure Python); and advanced users who either know Jinja already or are willing to learn to get a customised output. |
|
Thanks again @Bruntaz! This was really useful feedback and made me reconsider the CLI situation. I've just merged #288, which among other things adds a |
This adds a commandline flag
--hide-source, which disables the source of the documented functions from appearing in the output. I think the view source button is a great feature, but for many projects it is not acceptable to distribute the source of the function with the documentation because the source is proprietary and under copyright. For example, at my work we use Cython to compile and ship Python code to help obfuscate the source, but we also need to document the Python APIs that users will program against.This is mostly just a passthrough flag to change the behaviour of the Jinja template behind the scenes, but I think that hiding the source is a make-or-break feature for many users (including me) and expecting users to edit a Jinja template is far too big of a hurdle to expect people to actually jump over to use a "completely automatic" library.
I've set it to default to showing the source by default.