-
Notifications
You must be signed in to change notification settings - Fork 481
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
Allow for duplicate docstrings in @docs
and @autodocs
, issue #1079
#1570
Conversation
`Selectors.matcher( ::Type{AutoDocsBlock}, …)`
function Object(b::Binding, signature::Type) | ||
id_str :: AbstractString | ||
|
||
function Object(b::Binding, signature::Type, i_s :: AbstractString = "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function Object(b::Binding, signature::Type, i_s :: AbstractString = "") | |
function Object(b::Binding, signature::Type, i_s::AbstractString = "") |
@@ -273,6 +273,7 @@ end | |||
# ----- | |||
|
|||
function Selectors.runner(::Type{DocsBlocks}, x, page, doc) | |||
id_str = match(r"^@docs[ ]?(.*)$", first(split(x.language, ';', limit = 2)))[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the syntax should be
```@docs id="something"
```
instead? I think that pattern is used elsewhere for e.g. doctest filters etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do you ever care about the id
or just that it is unique?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the current approach follows the idea that is used in example blocks? there the id/name for continued examples is also just added with a space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea that's true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do you ever care about the
id
or just that it is unique?
If I remember correctly, I need the id_str
for the filtering mechanism in @index
blocks.
This filtering should allow to
- exclude docstrings with ids that are not empty from the listing
- and to list only a subset of docstrings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ever useful to have index with duplicates though? Perhaps there should be a canonical @docs
block or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ever useful to have index with duplicates though?
I guess not, and I am not sure myself anymore what I wanted this feature for.
I think it was primarily meant for exclusion of docstring subsets, but most of the use cases that come to mind can also be achieved with the Pages
kw.
The only (exotic) example I can think of is a single documentation page that has subsections (possibly containing duplicate docstrings in @docs
blocks) and an @index
is meant to be created for each subsection.
So, does it seem like this has a chance to be merged? In this case, I guess the main TODO is to adjust the documentation? Or is there any other major blocker? |
Yea, I am just not a big fan of the API here. If a
|
Yes, that's the main use case (for me personally, but also from what I gather at #1079). From how it looks in this line indeed every single docstring in a single As an alternative to the current syntax, maybe a new block type (e.g. |
Yea, I have definitely wanted that myself too at some point. I did not try this out, but one idea would be to only actually put the id if there are duplicates detected in the block. |
The problem I see with this approach (i.e., taking the user out of the loop) again is the behavior of
and a reference page
Without further hints from the user, |
Yea, my idea then would be that the one without an id would be the canonical one where all links would point to, and the duplicated one. Is it useful to be able to link to both of them individually? |
@manuelbb-upb: are you still interested on working on this? I agree with @fredrikekre's feedback, but I would go further and say that I am not sure that the whole unique
Things such as more fine grained filtering and marking individual docstrings as duplicate (as opposed to whole blocks) are things could be implemented later if the demand arises. |
@mortenpi As it is not that urgent a feature request, I should be able to find some time in the next few weeks to adapt the proposed code changes to your suggestions. |
This is a proposal on how to fix #1079.
By default, the standard behavior is maintained, that is, duplicate docstrings are not printed.
However,
@docs
and@autodocs
now allow for passing an id, i.e.The id will be Base64-encoded and used to compare objects and to define URLs; the default id is the empty string.
Docstrings from blocks with differing ids will be printed and have differing anchors.
Additionally,
@index
blocks will refer only to docstrings from blocks with the empty id string by default.This behavior can be changed by providing the keyword
include_ids
:I have not yet adapted the documentation for the proposed syntax.