Disclaimer
The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.
--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/f1df6215-9eb3-4b01-aa57-d31339995c9dn%40googlegroups.com.
Hi Stephen,
Pardon the late reply; I wanted to make some decisions and try things out before getting back to you.I've forked the sphinx-click repository and made a few modifications locally.Namely what I've added is:
- Anchors for groups and commands in the same dash-separated form as the rest (group, group-command).
- Extra anchors for options and arguments to conform to the same standard (`group-command-option`, `group-command-arg`)
- Namely if you have an option with multiple names, e.g. -v, --verbose for command `log` in the group `run`, you'll get both `run-log-v` and `run-log-version`.
- A new :hide-header: flag which hides the title, description and usage. If used with the ":nested: none" setting, this would produce an empty output, so in that specific case I made it only remove the title.
- A new nesting value which I very poorly named ":nested: complete" for lack of a better idea (suggestions are welcome). It's basically like the ":nested: full" setting but it also includes the short descriptions from ":nested: short" before it shows the full details. See attached screenshot below for an example.
I only have it working with my little experimentation project though. Haven't done any proper testing yet.Aside from that, I've written a small module to facilitate generating references using the added anchors to the documentation from within the docstrings of the CLI commands themselves.I don't know if that's of any interest to you - if so you're welcome to read on.I'll first explain why.I saw that if I put something like the following in a docstring for an example "starter order-soup" command:Soup goes great with :ref:`meat <main-order-meat>`, you know (just be sure to specify a good :option:`dish <main order-meat -dish>`).It works and generates the references.However, as you would expect, if you then ran the CLI tool and typed "cli starter order-soup --help", you would get exactly the above text, which is naturally not something you want to see in a CLI help message.So I wrote something that wraps Click's command decorators, parses the docstrings of each command and replaces the references with suitable text.I made it so that you can set some environment variable to say that you're currently building the documentation - if so then it replaces the text with references, otherwise it removes everything but the name.(By the way, do you know if there's a way to detect whether we're running Sphinx or the actual CLI without using an environment variable like that? That'd be nicer.)Since I transform the text in both instances I can be more flexible in format, so I made it so that you can type any of the following::type_of_reference:`Display Name Here <reference_path>`:type_of_reference:`reference_path``Display Name Here <reference_path>``reference_path`and you'll get a reference in Sphinx-generated documents and only the display names in the CLI itself.(The "type of reference" bit is to let you choose to use :option: instead of :ref: since that only works for options but also does some nice formatting.)If any of this is of interest to you I'd love to share it, so please tell me if so.
Aside from that, regarding what you said, I do think the documentation can be clearer about that specific point, and also I believe there's a copy/paste error there in the Cross-referencing section where it says:
Disclaimer
The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.
--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/f1df6215-9eb3-4b01-aa57-d31339995c9dn%40googlegroups.com.
Hey Stephen,Thanks for your reply,I'll draft what I have into a PR hopefully tomorrow or the next day.
I would love some feedback, yes. Considering how little I still know about all this, I'm sure there are better ways of doing what I did.:nested: fuller, while clear, sounds a bit silly to me. XDMaybe "verbose"?
Well, I'll include it in the PR and you're welcome to decide for yourself if you want to add it and what to call it if so.I didn't know about the form feed character, that's a useful tip.I don't think it would solve the issue, however, as that seems to be used for truncating everything that follows, so I wouldn't be able to use that to change inline references.
What I made seems to be working decently enough for now, at least.Considering it modifies Click objects, it might be a good idea to make it into a plugin like you said. I actually didn't know Click supported plugins. I'll look into that.One more thing I've added to my forked repo is a ":post-process: path.to.module:function_name" option that lets you inject code to post-process generated nodes for each command.In terms of amount of change to sphinx-click, there isn't much there - just loading the module and then calling the specified function on the list of nodes at the end of the _generate_nodes() function.But adding it allowed me to add per-command customization. I don't know how much something like that will be used by other people, but personally I've found it to be very useful.
I also have a working version of the documentation generation tool now.Also without proper testing so far, unfortunately... this entire thing I'm doing is one big POC so I need to get it into presentable form and see that everything I have in mind is possible before I can take the time to do the rest of it.