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
doc.kak: Also search through plugins (stdlib and per-user) for docs. #3704
Conversation
This makes the somewhat-dubious assumption that every plugin will have uniquely- named documentation files, instead of automatically putting every plugin's docs into a namespace. However, plugins already have to deal with flat namespaces for commands, options, filetypes, etc. so one more shouldn't hurt. Fixes mawww#2466.
This is a great initiative! I think it would help a lot with new user experience too, since many people look for tools like linting or window management which are already covered by stdlib but they are not very easy to figure out. Documentation for them sometimes exists in the Github wiki but it is not very discoverable. It'd be great if we had docs for the tools that ship with Kakoune like you started doing. |
I'm not sure this is usable because the hardest and most important questions about built-in scripts documentation still stand. Where is the documentation supposed to be located? I'm not convinced storing it in the same directory as the .kak files is the right way. Should we assume documentation files can be overridden through Are we going to manually write all the documentation, making it a massive maintenance burden? It'd be more productive to have a PR that auto-generates it (using a separate script? a CLI flag that uses the internals?). Ideally there shouldn't be any manual modification made to the resulting flag, we can fit all the information needed into docstrings. |
- some wording changes in included documentation - find supports multiple starting paths, we don't need to launch it 3 times - Change the regex that trims the file extension to only trim the last extension Some additional things I noticed: - find should use -L to see through symlinks like the autoload processing does. - find should check the user's autoload directory first, so users can override Kakoune's built-in documentation.
When it comes to third-party plugins, either we support documentation beside plugin code, or users need a plugin manager to install all the different parts of the plugin into all the different places they need to go. The fact that Kakoune doesn't need a plugin manager today is something I value, and I'd like to see that continue to be the case. Storing the documentation for standard-library plugins beside their .kak files is less important, but it does provide an example for third-party plugin authors to follow.
Ideally documentation should work the same way as plugins do - if
@krobelus pointed out that wasn't necessary, and I've fixed it.
The nice thing is we don't have to write it all at once - most of the modules have gone this long without any kind of online documentation, they can go a little longer. The other nice thing is that writing and updating documentation is an awful lot easier than learning C++. I bet there's a lot of people who use Kakoune for writing Python or Rust or JavaScript or Markdown who would like to contribute, who don't have time to learn C++ but could pretty easily take 10 minutes to document a plugin — especially once there's a bunch of examples to follow. Honestly, if this PR (or something like it) lands, I expect third-party plugins to adopt it really quickly, and standard-library plugins very slowly or not-at-all.
Today, people put a bunch of information into docstrings because there's no other way to attach documentation to things. And so, when I added some example documentation to this PR, I copy/pasted docstrings because they were easy to find. However, because they're easy to find, we probably don't actually need to write them down separately. Instead, plugin documentation should talk about how to use all the commands and options together, and leave the command/option docstrings where they are. I've updated my PR to remove the "commands" and "options" sections from the example documentation, and to focus on documenting how to use the plugin as a whole. |
I don't think duplicating the docstring in the doc file is a bad idea. That is what happens for built-in commands in |
One of the things I miss from Emacs is the ability to quickly go to the implementation of any function. If we take this PR I'd like to see the rc-file docs have a "go to source" link that does an
Which issues? I assume some of the points raised here I guess that this adding more pages further emphasizes the need for some kind of
Existing plugins are usually documented in a README.md. Supporting that might An idea is to have documentation at the beginning of an rc file, though that
Accidentally overriding docs could be a problem in future but I think that's minor.
With the updated version that does not duplicate docstrings this seems better.
Yeah that makes sense. |
The most important thing I wanted to do with this PR was allow third-party plugins the same access to Kakoune's online documentation that "native" code has, and I think the code changes in this PR achieve that goal — especially now that I've included krobelus' suggestions. The second thing I wanted to do was to provide a model for third-party plugins to follow, so they can feel consistent with Kakoune's native documentation and with each other. Also, this helps first-time documentation writers make sure they've covered all the basics, leading to better quality documentation overall. The exact content of the model is not as important as the existence of a model — docs aren't written in stone, after all. Nevertheless, I think it's useful to spend some time thinking about what should be in plugin docs. Using the grand unified theory of documentation as a base, I think the primary plugin docs should mostly be "explanation" content, since "reference" content is better suited to docstrings, and tutorials and how-to guides tend to be whole documents in themselves. I'm open to the idea of plugin docs including reference content, since it can be handy when your particular instance of Kakoune doesn't have the docstrings loaded (for example, the tmux module isn't loaded when Kakoune runs outside of tmux). On the other hand, if Kakoune's maintainers are worried about maintaining consistency between docstrings and prose documentation, I'm quite happy to give them up. I think just adding explanation content for Kakoune's standard plugins would be a big improvement. Today, the only documentation for the format the lint plugin expects is in the There's certainly a lot more that could be done with Kakoune's documentation, including automatically generating AsciiDoc from docstrings, cross-linking between defined items and their documentation, and all the things a fancy documentation system like Sphinx can do. However, I have no idea what that would look like, or how to get there from here, so I don't think it's worthwhile trying to think that far ahead.
I wrote the current
I don't think it's practical to support existing third-party plugin docs as-is, since there's no standards or conventions. It's much more practical to set up a convention and plugins can conform to it if they want the nice integration. I'd hope the convention would be somethnig like:
|
Also, make sure docstrings reference the prose docs, so people who stumble over an interesting-looking command or option can find out more about it.
As a better illustration of what I mean, I've amended |
I agree, having some convention for integrated documentation is much better than having none. The new |
Did not look at the implementation yet, but one quick question comes to mind, should we require a |
I looked at the top 12 plugins in https://kakoune.org/plugins.html to check their current documentation conventions. Of those:
I expect most plugins will be completely unaffected by this change. Even for the plugins that are affected, the I haven't surveyed plugin authors or anything, but I expect that if this change lands, I expect they'll be happy to rename/split/reformat their docs to match the new conventions (especially since Pandoc can automatically convert Markdown to AsciiDoc). Perhaps I should start a thread on the forum/subreddit canvassing people's opinions? |
This makes the somewhat-dubious assumption that every plugin will have uniquely-named documentation files, instead of automatically putting every plugin's docs into a namespace. However, plugins already have to deal with flat namespaces for commands, options, filetypes, etc. so one more shouldn't hurt.
Also includes some documentation for a few standard plugins (doc.kak itself, autoreload.kak, lint.kak) so you can see the change in action, and as a proposal for how plugin documentation might be organised.