-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Can the format of the auto-generated doc comments be updated? #1012
Comments
Personnally, I don't this proposition for several reasons.
I guess you put But nothing garantee, that So here, we are making several assumption.
If we use They should be in red if the grammar accepted them as valid: It's also important to note that the markdown parser used by F# Formatting isn't 100% compliant with the markdown specs and so it's possible that the wrong display where it display For me, we should not change the current generation. But a fix should be provided to F# Formatting or just use a pre-processor steps in your build process to convert the comments into "optimized" comment for F# Formatting. Because current, format is easy enough to process using one regex to archieve the format you are expecting. |
That's fine, I'd be happy with a single
You're right here, I missed that FSF isn't converting the |
I'm pretty sure this looks bad in VSCode tooltips tho. And looking nice in VSCode tooltips is a strong requirement for this feature - otherwise, people will just hate it. I'd rather modify/fix F#.Formatting - as this is something we can control (unlike VSCode tooltips rendering). |
@baronfel If we use a single And in VSCode you get this result: For me, the current way of writing docs comments is just syntax sugar to replace the XML version. Also, each docs comments should be considered independently because they are not related to each other. So each time we create a docs comment, we are in fact creating a "section". If F# formatting is considering that it can parse And using I am not telling that the correct way of doing is perfect. But I see more cons to change the docs comments when the bug is inside F# formatting. |
Looking at Rust's doc comments they use They do however look gross in VSCode too. I'm not sure this is really a bug in FSharp.Formatting. Overloading What about if we used |
Do we have any consensus regarding this issue? TBF, I'm in favour of just leaving it as-is - it seems we don't have any solution that makes the situation better for everyone. |
I remember talking with someone (Don? Eugene? ) about it on last F# eXchange - suggestion was to actually generate XMLDoc format. We can interpret XMLDoc format correctly (i.e. it will produce nicely formatted tooltip in Code) and it will be more compatible with the other tooling (which often doesn't render markdown - VS/Rider) |
I've done some experimentation here and the xmldoc parsing could be better in general. In markdown we'd like to do bullets for lists, and there is xmldoc syntax for this, but no major editor that I can see translates the I do agree that making it easier to write good, compatible comments would be great. Or contribute a markdown frontend that the compiler would translate from MD->XML for tooling 🧌 |
After thinking about it, we should indeed aim for better compatibility. What is the |
@MangelMaxime sorry, that was a formatting issue with my message. I was meaning the list and/or item elements mentioned in the C# documentation comments pages. And yes those are C# docs, but I think it's reasonable to support those. |
Boo, I guess looking at the actual F# docs those tags aren't supported/recognized: |
I suspect F# XML doc to be a subset of C# XML documentation. And because sometime we are accessing C# libraries it make sense to support everything :) And sure supporting the list items should not be difficult even supporting the type I wanted to look again at the XML/Markdown formatter because I saw some regression (or bugs?) in it compare to what I remembered from Ionide 3. @Krzysztof-Cieslak Can I try looking at updating the auto generated doc comments to use XML instead of Markdown? |
I;m fairly sure F# support exactly the same XML Docs tags as C#, just this documentation is not complete CC: @cartermp |
@MangelMaxime, sure, go ahead. |
Sample code and how tips appear: module Say =
///<summary>here is some summary</summary>
///<remarks>
/// with remarks
///<list type="bullet">
///<item>and here is an item</item>
///</list>
///</remarks>
let hello name =
printfn "Hello %s" name And I couldn't get a build/tooltip out of VS for Mac at all. It seems like there are a few pieces here:
Thoughts? |
Yes, this is what I will be working at first
I will make a pass on this one too when generation is ok. Like that I will be able to test how things looks :)
I think FSAC is reading the doc comments both from FCS when it in your corrent code and the xml file when it's a package. FCS gives back the raw XML which is normal because it can't assume the language use for formatting the code. I don't think there is much to do here. |
Update we have a PR #1175 ready for generating XML comment instead of markdown. I am now taking a look to support good display for all the XML comment features. |
I love it so far, you're wonderful for tackling this. |
I opened an issue to see if we could allow "Command URL" in the tooltip. This would allow us to open the |
I am working on the Tooltip improvements and I need helps to take decisions. So, here is the situation:
So we have two implementations.
Can we remove the Ionide implementation, I think it could be handled inside FSAC no? If we do so, we could decide to have only one implementation in FSAC. Because handling one implementation is already hard enough. The docs format are hard enough to implement correctly in one parser because the XML comments are not consistent some are using 2, 3, 4 spaces indentation, the XML specials chars are not always escaped, etc. |
|
I agree, will include the changes for it in my PR.
I can port the fixed from the The only drawback of |
Yeah, let's do that. |
@Krzysztof-Cieslak Thank you for giving me a test for table support :) Current state of the tooltip: It demonstrates all the XML comment feature except:
We support an extra feature for For example: Of course, I will mention it in the FSAC PR and so maintainers can decide if they do want this extra feature or no. |
Ok so... Microsoft is using tags, property and syntax that aren't documented... For example: <member name="M:System.Uri.#ctor(System.String)">
<summary>Initializes a new instance of the
<see cref="T:System.Uri"></see> class with the specified URI.
</summary>
<param name="uriString">A URI.</param>
<exception cref="T:System.ArgumentNullException">
<paramref name="uriString">uriString</paramref> is null.
</exception>
<exception cref="T:System.UriFormatException">
<block subset="none" type="note">
In the
<a href="http://go.microsoft.com/fwlink/?LinkID=247912" data-raw-source="[.NET for Windows Store apps](http://go.microsoft.com/fwlink/?LinkID=247912)" sourcefile="netstandard.yml" sourcestartlinenumber="3" sourceendlinenumber="3">.NET for Windows Store apps</a> or the
<a href="~/docs/standard/cross-platform/cross-platform-development-with-the-portable-class-library.md" data-raw-source="[Portable Class Library](~/docs/standard/cross-platform/cross-platform-development-with-the-portable-class-library.md)" sourcefile="netstandard.yml" sourcestartlinenumber="3" sourceendlinenumber="3">Portable Class Library</a>, catch the base class exception,
<xref href="System.FormatException"></xref>, instead.
</block>
<code data-dev-comment-type="paramref">uriString</code> is empty.
-or-
The scheme specified in
<code data-dev-comment-type="paramref">uriString</code> is not correctly formed. See
<xref href="System.Uri.CheckSchemeName(System.String)"></xref>.
-or-
<code data-dev-comment-type="paramref">uriString</code> contains too many slashes.
-or-
The password specified in
<code data-dev-comment-type="paramref">uriString</code> is not valid.
-or-
The host name specified in
<code data-dev-comment-type="paramref">uriString</code> is not valid.
-or-
The file name specified in
<code data-dev-comment-type="paramref">uriString</code> is not valid.
-or-
The user name specified in
<code data-dev-comment-type="paramref">uriString</code> is not valid.
-or-
The host or authority name specified in
<code data-dev-comment-type="paramref">uriString</code> cannot be terminated by backslashes.
-or-
The port number specified in
<code data-dev-comment-type="paramref">uriString</code> is not valid or cannot be parsed.
-or-
The length of
<code data-dev-comment-type="paramref">uriString</code> exceeds 65519 characters.
-or-
The length of the scheme specified in
<code data-dev-comment-type="paramref">uriString</code> exceeds 1023 characters.
-or-
There is an invalid character sequence in
<code data-dev-comment-type="paramref">uriString</code>.
-or-
The MS-DOS path specified in
<code data-dev-comment-type="paramref">uriString</code> must start with c:\\.
</exception>
</member> I should have never looked at |
Yes, they also have places where it's not valid XML in |
Update of the day :) Today I added support for Example taken from <?xml version="1.0" encoding="utf-8"?>
<doc>
<assembly><name>testLibrary</name></assembly>
<members>
<member name="P:TestLibrary.testEverything">
<summary></summary>
<exception cref="T:System.UriFormatException"><block subset="none" type="note">
In the <a href="http://go.microsoft.com/fwlink/?LinkID=247912" data-raw-source="[.NET for Windows Store apps](http://go.microsoft.com/fwlink/?LinkID=247912)" sourcefile="netstandard.yml" sourcestartlinenumber="3" sourceendlinenumber="3">.NET for Windows Store apps</a> or the <a href="~/docs/standard/cross-platform/cross-platform-development-with-the-portable-class-library.md" data-raw-source="[Portable Class Library](~/docs/standard/cross-platform/cross-platform-development-with-the-portable-class-library.md)" sourcefile="netstandard.yml" sourcestartlinenumber="3" sourceendlinenumber="3">Portable Class Library</a>, catch the base class exception, <xref href="System.FormatException"></xref>, instead.
</block>
<code data-dev-comment-type="paramref">uriString</code> is empty.
-or-
The scheme specified in <code data-dev-comment-type="paramref">uriString</code> is not correctly formed. See <xref href="System.Uri.CheckSchemeName(System.String)"></xref>.
-or-
<code data-dev-comment-type="paramref">uriString</code> contains too many slashes.
-or-
The password specified in <code data-dev-comment-type="paramref">uriString</code> is not valid.
-or-
The host name specified in <code data-dev-comment-type="paramref">uriString</code> is not valid.
-or-
The file name specified in <code data-dev-comment-type="paramref">uriString</code> is not valid.
-or-
The user name specified in <code data-dev-comment-type="paramref">uriString</code> is not valid.
-or-
The host or authority name specified in <code data-dev-comment-type="paramref">uriString</code> cannot be terminated by backslashes.
-or-
The port number specified in <code data-dev-comment-type="paramref">uriString</code> is not valid or cannot be parsed.
-or-
The length of <code data-dev-comment-type="paramref">uriString</code> exceeds 65519 characters.
-or-
The length of the scheme specified in <code data-dev-comment-type="paramref">uriString</code> exceeds 1023 characters.
-or-
There is an invalid character sequence in <code data-dev-comment-type="paramref">uriString</code>.
-or-
The MS-DOS path specified in <code data-dev-comment-type="paramref">uriString</code> must start with c:\\.
</exception>
</member>
</members>
</doc> Here is my proposition: I first show only a See how now the exception item detect if it should be rendered on a single line or using multiples lines. Here is how Microsoft is rendering it on its website: My question, is are you ok with my proposition? I intentionally added an extra indentation level and kept the |
For info, I am moving the conversation in the FSAC PR: ionide/FsAutoComplete#446 Now that I have almost everything in it, it will make it easier to discuss with others maintainers etc. And also, now the implementation is public so I can use it as an example to explains things if needed. |
Well, this was done a few versions ago. Huge props to @MangelMaxime for working on it. |
I noticed while working on doc generation in MiniScaffold that the markdown rendered by FSharp.Formatting is a little rough when the sections are delimited by
*
instead of#
headings. When#
are provided the parser gives a lot more detail to the structure that we can use to render sections a bit better, so I'd like to see if you are open to changing the current auto-generated comment headings.Let me give an example of the structure we get back from FSharp.Formatting in different scenarios. Here is our sample code:
and here is the matching Comment structure for the
helloPerson
comment block:Some things to note here are
FullText
in somewhere you'd get a messy, inline blob:Now let's take a look at what the structure for the
nothing
function is:In this case the
FullText
is useful, semantic markup and renders nicely by default. However, the bigger win here is that theh
nodes are parsed into sections and so can be treated differently based on the kind of section they are. We could begin to establish some convention around the content of the particular sections, for example.Also, with four
#
this still looks good in ionide out of the box:Having those sections makes it really easy to write code consuming the comment, like I did here: https://github.com/TheAngryByrd/MiniScaffold/blob/28dc42dd88018eddfa1a35bea99618787d0fc6ed/Content/Library/docsSrc/templates/partMembers.fsx#L99-L114. Right now the section name is just an h2, but it could be any kind of styling I wanted.
What do you think?
The text was updated successfully, but these errors were encountered: