-
Notifications
You must be signed in to change notification settings - Fork 100
Render documentation attached to includes #647
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
Conversation
@@ -24,11 +24,6 @@ <h1> | |||
</header> | |||
<div class="odoc-content"> | |||
<div class="odoc-include"> | |||
<div class="spec-doc"> | |||
<p> | |||
Doc of <code>T</code>, part 2. |
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.
This is removed because there is a documentation attached but it renders to nothing.
Some elements don't render to anything, for example @inline
tags.
We could decide it's fine or we could add an exception for for elements that do not render ? cc @dbuenzli
Unrelated thought: Should we handle tags specifically ?
Currently, it's possible to have tags in the middle of a comment or in the middle of the preamble.
I don't see tags as markup elements like headings and paragraphs but as metadata attached directly to the declarations. I'd expect them on the same hierarchical level as the documentation text, not inside it.
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.
We could decide it's fine or we could add an exception for for elements that do not render ? cc @dbuenzli
I don't understand the question. Also:
Now, the attached documentation is rendered entirely and the includee top-comment is not.
The top-comment may already have docs, e.g. headings and paragraphs, I think you want these rendered. Did you want to say that you drop the preamble ?
I don't want to sound like a broken record but I think the only way to get to a consistent system is to think about these things in terms of synopse, preamble and content, not in terms of comments.
I don't see tags as markup elements like headings and paragraphs but as metadata attached directly to the declarations. I'd expect them on the same hierarchical level as the documentation text, not inside it.
That would be my understanding as well. But:
I don't see tags as markup elements like headings and paragraphs but as metadata attached directly to the declarations.
They are still placed by end-users as they see it fit so I think we should consider them as block-level stuff (and consecutive sequences of tags should define a single block, not done yet see #607)
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.
On a regular declaration the preamble would be the tag then the paragraph but we agreed in #645 that includes are different, there is no preamble ever generated, we either take the decl comment entirely or make a synopsis from T's top-comment.
The problem I'm mentioning is that in this case:
module type T = sig
(** Top-comment of T. *)
end
include T
(** @inline *)
the decl comment renders to nothing but is not technically empty so we won't attempt to take the synopsis out of T
. Potential fixes:
- Decide it's OK
- Consider tags targeted at Odoc are not part of the doc (they are not rendered currently but are part of the markup:
canonical
,inline
,open
,closed
) - Handle tags at a different level and render them separately (eg. always after the documentation, wherever they are placed by the user). Like the previous point but applies to every tags and changes the layout.
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.
- Consider tags targeted at Odoc are not part of the doc (they are not rendered currently but are part of the markup:
canonical
,inline
,open
,closed
)
Ah yes thanks for the clarifification. I'd say that this is the right idea.
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.
The document part of the code looks ok to me.
is no documentation. *) | ||
if t.doc <> [] then Comment.to_ir t.doc | ||
else Comment.synopsis ~decl_doc:[] ~expansion_doc:(Some sg_doc) | ||
in |
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 first_to_ir
still use after that ?
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.
No, it's removed.
Before, the attached documentation was removed and the synopsis from the includee top-comment was used instead. Now, the attached documentation is rendered entirely and the includee top-comment is not. There is an exception, if there is no documentation attached to the include, we render the synopsis extracted from the includee top-comment, as before.
Removes the exception added in the previous commit. We don't fallback to rendering the synopsis when there is no documentation attached.
1d08e6e
to
b421e25
Compare
I've removed the fallback of rendering the synopsis extracted from the expansion when there is no doc attached to the |
I would still suggest to only drop the synopsis and preamble, not the whole top comment. But I won't insist… |
The top-comment from the included module type is dropped entirely. Do you suggest including it but cutting out some bits ? |
I'm suggesting dropping both the synopsis and the preamble and including everything that comes after the preamble.
The problem is that most people writing these comments won't be aware of that. Namely to most persons writing module M : sig
(** Synopsis
Preamble
{1:prims Primitive functions} *)
val f : …
(** [f] is *)
end
module M : sig
(** Synopsis
Preamble *)
(** {1:prims Primitive functions} *)
val f : …
(** [f] is *)
end However that will result in two different inclusions for the person who includes – who is likely not the same person. In other words if the person who includes looks at the rendering of |
What you are suggesting is consistent with the "stop the preamble at the first heading" rule. A generalization might be that if there is a heading in the top-comment, that heading and everything after it is treated as an extra floating comment.
I don't agree with this. I wouldn't have expected one solution more likely than the other. After learning how comments are attached, I would absolutely expect the first and second comments to be handled differently. |
That's a bit besides the point I'm making which is from the point of the person who includes. Of course it's always possible to be subtle, but subtle doesn't necessarily make things usable. In practice people are not going to look at the comment structure of the things they include, especially since these may not be their libraries. For example when I So if you want least surprise and least bug reports of the form "this is not expected" for |
Fixes #645
Before, the attached documentation was removed and the synopsis from the includee top-comment was used instead. Now, the attached documentation is rendered entirely and the includee top-comment is not.
There is an exception, if there is no documentation attached to the include, we render the synopsis extracted from the includee top-comment, as before.
This is on top of #643 to avoid conflicts.