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

Option to disable type-encoding in docstring URLs #2608

Open
kbarros opened this issue Nov 15, 2024 · 1 comment
Open

Option to disable type-encoding in docstring URLs #2608

kbarros opened this issue Nov 15, 2024 · 1 comment

Comments

@kbarros
Copy link

kbarros commented Nov 15, 2024

Is there a way to get simple URLs to docstrings created with @autodocs? For example, this URL is very long because it encodes all type information:
https://sunnysuite.github.io/Sunny.jl/dev/library.html#Sunny.set_pair_coupling!-Union{Tuple{N},%20Tuple{System{N},%20AbstractMatrix,%20Any}}%20where%20N

In my case, I define only one docstring per function, and it is not necessary to encode the type information in the URL.

Feature request: An option to generate simple URLs that look like this instead of the above:
https://sunnysuite.github.io/Sunny.jl/dev/library.html#Sunny.set_pair_coupling!

If that's not possible, then maybe a workaround is to put docstrings on function stubs like so:

"""
    MyDocString
"""
function set_pair_coupling! end

function set_pair_coupling!(...)
     <actual implementation>
end
@goerz
Copy link
Member

goerz commented Nov 15, 2024

To add a bit of background: Documenter has both function docstrings and method docstrings as separate categories. The function docstring is the concatenation of the method docstrings. When you use an explicit @docs block, you can choose which one you want. As explained in the documentation, if you do

```@docs
set_pair_coupling!
```

you get a function docstring, but if you do something like

```@docs
set_pair_coupling!(::System, ::Any, ::Any)
```

you get a method docstring.

The "issue" is that @autodocs expands into a list of method docstrings, not function docstrings. This isn't documented behavior, so I'm not sure how intentional it is. My choice would have been to default to function docstrings. I suppose the drawback of that is that you then can't like to a specific method with @ref.

But anyway, I don't see any reason that @autodocs couldn't have an option to switch between expanding to method docstrings and function docstrings, so presumably an PR that adds such an option would be welcome.

I do agree that the long URLs generated by the current @autodocs block are somewhat annoying. It's one reason I don't use @autodocs, personally, but use my own project-specific generate_api.jl scripts to generate Markdown documents with @docs blocks. Also, in the context of DocumenterInterLinks I added a workaround that at least allows to avoid the long method specifications for @extref links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants