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

Add documentation to @doc and other documentation components that they could contain markdown or other formatting #171

Closed
johanste opened this issue Jan 14, 2022 · 5 comments · Fixed by #6146
Assignees
Labels
1_0_E2E design:accepted Proposal for design has been discussed and accepted. triaged:core
Milestone

Comments

@johanste
Copy link
Contributor

Rich text formatting in descriptions/documentation

Documentation for APIs often involve more than just raw text. Common reasons to use rich text formatting include rendering of tables or embedding links into the generated reference documentation.

For an example, see the APIM List By Tags endpoint which illustrates the attempt to use (valid) openapi descriptions that contains a table in the API documentation as well as the issue with tools treating description fields as plain text (broken rendering).

OpenAPI support for rich text

OpenAPI allows for rich text formatting in description fields using CommonMark. As evident from the example above, there are gaps in our toolset with regards to how rich text is handled.

Possible solution

  • Only support CommonMark for input.
  • Add new @richDoc decorator for rich documentation that takes a format parameter. The only supported value (for now) is CommonMark.
@richDoc(
"""
|One|Two|
|-|-|
|1|2|
|3|4|
""", "CommonMark")
model ModelWithTableDocs {};

Alternate solution

Change the @doc decorator so that it accepts CommonMark instead of raw text. For the most part, that is an extension to its current decorator definition (in most cases, you don't have accidental markup in the raw text), but it adds complexity to emitters since they have to sniff the format/convert to something they can manage or risk broken rendering as shown above.

Challenges/questions:

  • There are many rich language definitions *in adition to CommonMark), as well as different dialects within a dialect. Is it enough to support just CommonMark?
  • Client and service library code emitters want to emit descriptions as docstring/comments in generated code. Some langauges (e.g. Python) have idiomatic formats for rich text (in the case of Python, reStructuredText) but most languages expect plain text in their descriptions. Do we expect multiple formats in the specification or do we provide converters?
@markcowl markcowl added the design:needed A design request has been raised that needs a proposal label Jan 21, 2022
@markcowl markcowl added this to the Backlog milestone Jan 21, 2022
@markcowl
Copy link
Contributor

Notes from design meeting

  • Team is leaning toward format-specific decorators, rather than a format parameter
  • Agreed that we should use the second (optional) parameter for value substitution in the document string @richdoc("{name}", <type-with-name>)
  • Broaden proposal to include all the doc types and how we would represent
    • documentation types we would present
      • textual documentation
      • formatted documentation (commonMark, Html, others?)
      • example values
      • operation examples
      • external documentation files
    • how these map into different documentation targets
    • What we need for internal documents (include in azure-specific libraries)
    • What we should surface to external users in the core

@markcowl markcowl modified the milestones: Backlog, [2022] May Mar 29, 2022
@markcowl markcowl modified the milestones: [2022] May, Backlog May 11, 2022
@tjprescott
Copy link
Member

From the most recent review with the API review board, they weren't a fan of HTML in the docstrings and would prefer something like markdown.

@mikekistler
Copy link
Member

I think the answer here is to just state that @doc/doc comments can support markdown -- we could treat it as a documentation issue.

@markcowl
Copy link
Contributor

markcowl commented Sep 9, 2023

Implementation issue for beta is just documentation, per Mike's comment and discussion

@markcowl markcowl assigned markcowl and unassigned johanste and mikekistler Sep 11, 2023
@markcowl markcowl removed this from the [2023] December milestone Dec 5, 2023
@markcowl markcowl added this to the [2024] January milestone Dec 5, 2023
@markcowl markcowl modified the milestones: [2024] January, [2024] March Jan 25, 2024
@markcowl markcowl removed the design:needed A design request has been raised that needs a proposal label Jan 29, 2024
@markcowl markcowl changed the title Support rich text formatting for documentation/descriptions Add documentation to @doc and other documentation components that they could contain markdown or other formatting Jan 29, 2024
@markcowl markcowl removed their assignment Jan 29, 2024
@markcowl markcowl modified the milestone: [2024] March Jan 29, 2024
@markcowl
Copy link
Contributor

markcowl commented Feb 5, 2024

est: 1, pri: 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1_0_E2E design:accepted Proposal for design has been discussed and accepted. triaged:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants