Skip to content

Libdoc: Support documentation written with Markdown #5304

Closed

Description

@Wolfe1

It seems this was discussed briefly back in 2016 but I wanted to see if there was any thoughts on supporting the Markdown format for Libdoc in 2015.

With Markdown being the preferred(currently only?) markup for copilot knowledge bases, this would be a helpful enhancement for anyone trying to leverage specific library documentation for their copilot code generation or autocompletes.

Due to the complexity of the HTML of the libdoc outputs they don't seem to work through any HTML to Mardown conversion tools so perhaps a more simplified Libdoc HTML output would work as well?

Activity

  1. pekkaklarck commented on Jan 9, 2025

    @pekkaklarck
    Member

    Good timing, we have been talking about Markdown and other doc formats quite a lot recently. The reason is that we want to re-implement the User Guide using some better tech than the current reStructuredText based custom solution, and after evaluating alternatives we decided to move to Markdown and MkDocs. Now that we are moving to Markdown with our most important documentation, it makes sense to convert other docs to it too and to support it with Robot Framework itself as well. In the long run I'd like Markdown to be the default syntax used in library docs and in documentation used in Robot data, but due to backwards compatibility reasons getting there takes time. Libdoc getting Markdown support would be an important step to that direction.

    Notice that issue #2476 that you referred to actually proposes making it possible for Libdoc to produce Markdown outputs. I can see that being useful as well, but the first step should be adding support to generate documentation based on Markdown input. I'd like this issue to concentrate on that and a separate issue submitted about Markdown outputs (or we could just re-open #2476).

  2. changed the title [-]Libdoc Markdown Format[/-] [+]Libdoc: Support documentation written with Markdown[/+] on Jan 9, 2025
  3. pekkaklarck commented on Jan 9, 2025

    @pekkaklarck
    Member

    One big problem with Markdown is that it isn't supported by Python natively. This is a problem, because we don't want to have any mandatory external dependencies because they make installation more complicated on environments without Internet connection. That wouldn't be a problem with Libdoc (it needs an external module to support reStructuredText as well), but if we want to support Markdown also in Robot data going forward, this needs to be taken into account. In practice we need to "vendor" a suitable Markdown module to make sure it's always available.

    A problem with vendoring a Markdown module is that we need to choose which one to use. There are at least five alternatives, all of them being actively maintained and none hugely more popular than others. I actually asked about recommendations on the Python discussion forum and listed these alternatives, but I got no replies. Since then I've got some exposure to Python-Markdown because MkDocs uses it, and the experience has been fine. One benefit is the huge variety of plugins that make it possible to support non-standard (well, there's no real Markdown standard to begin with...) but commonly used Markdown features (I guess we'd like to get close to GitHub Flavored Markdown). Another benefit is that making custom plugins is pretty easy. That's important because we most likely need a custom plugin to make cross-reference linking between keywords convenient. I think using Python-Markdown would thus be a good choice, but if others have experience from other modules, we can still consider alternatives.

  4. pekkaklarck commented on Jan 9, 2025

    @pekkaklarck
    Member

    I believe the main steps to add Markdown support to Libdoc would be:

    • Choose the Markdown module to use. This is discussed in the above comment and Python-Markdown is a strong candidate.
    • Vendor the module. I believe we should add a dedicated robot._vendor package for this purpose. We can use it also with other possible vendored modules later. Update: Not done at least in RF 7.5.
    • Expose Markdown to HTML conversion functionality via a new function under robot.utils. This function would obviously use the vendored Markdown module, but its API shouldn't be tied to it. That allows changing the Markdown module in the future if needed. Update: Turned out that using the markdown module directly is easier.
    • Add Markdown support to Libdoc itself. It basically requires supporting Markdown (case-insensitively) as a value with the ROBOT_LIBRARY_DOC_FORMAT attribute and with the --docformat option, and then converting documentation to HTML.
    • Add support to link to other keywords and preferably also to section headers in the same library. This most likely requires writing a plugin to the Markdown module we use and, before that, deciding on the syntax to use. See the User Guide to see how such linking works currently.
    • Decide which convention to recommend for documenting arguments. This is not a mandatory part of this issue, but in the future we may want to parse the argument information and that is a lot easier if the information is available consistently. In practice the alternatives are the Google-style and the Numbydoc-style. I don't have a strong preference, but I think the former looks a little bit better. Notice that we need to make the same decision also with Robot's API docs (we plan to convert them to Markdown too) and for consistency we should use the same format in both cases. For more details about this overall topic see here. Update: This is covered by Libdoc: Argument and return value documentation syntax #5604.

    Possible future enhancement include support for resource file documentation using Markdown, Markdown outputs (that was already discussed in my first comment), support for spec files with Markdown docs even if the original format would be something else (that will likely require another dependency), making Markdown the default documentation format, and so on. I'd like to keep all these out of the scope of this issue, though, and concentrate on getting the basic support for writing library documentation using Markdown.

  5. pekkaklarck commented on Jan 9, 2025

    @pekkaklarck
    Member

    I believe this would be a great feature in general and especially now that we are moving to Markdown also otherwise. I assign this tentatively to RF 7.3 scope, but we haven't yet started release planning so I cannot promise this will be included. Are you @Wolfe1, or someone else, possibly interested to help?

  6. added this to the v7.3 milestone on Jan 9, 2025
  7. modified the milestones: v7.3, v7.4 on Apr 4, 2025
  8. fkromer commented on Apr 15, 2025

    @fkromer

    W.r.t. docstring styles: There is Epytext style as well. But griffe does not support it and it’s worth putting this limitation into the libdoc docs I guess. Support for documentation metadata in type annotations (PEP727) would be pretty cool.

  9. 25 remaining items

  10. pekkaklarck commented on Aug 29, 2026

    @pekkaklarck
    Member

    As discussed earlier, we added admonition support using Python-Markdowns admonition plugin. There are, however, two major problems with that:

    1. The plugin uses custom syntax that is not widely used otherwise. It is unlikely that other tools processing Markdown understand it. This problem got a bit bigger when we added Markdown output support to Libdoc (Libdoc: Support Markdown as output format #5749) and these outputs can be passed forward to other tools.
    2. The plugin itself has been put into maintenance mode since we took it into use.

    Due to the above problems I believe we shouldn't use the Python-Markdown admonition syntax. I consider admonitions a useful feature, though, so I wouldn't like to remove the functionality altogether. I believe a better solution is switching to the following syntax that is used, for example, by GitHub, Microsoft Learn and Obsidian:

    > [!NOTE]
    > Note text here. It can span multiple
    > lines and contain *formatting*.
    

    This is how the above renders here:

    Note

    Note text here. It can span multiple
    lines and contain formatting.

    Obsidian and some other tools support also an optional title:

    > [!CAUTION] Optional title
    > Titles are not supported on GitHub.
    

    There are also other syntax alternatives (see e.g. :::note syntax used by Docusaurus), but the above style seems to be more widely used. It also has a great benefit that it is based on the Markdown blockquote syntax, so all Markdown tools should render it reasonably well. In practice the results will look similar to this:

    [NOTE]
    ! missing above so not recognized as an admonition.

    Because Python-Markdown doesn't support this syntax itself, we need a plugin. There seem to be external plugins available, but I don't want to have a dependency for feature like. Because Python-Markdown already parses this syntax to a blockquote, implementing a custom plugin is also pretty easy. We already have a custom plugin for URL auto-linking as well.

    I believe we should change our admonition syntax to the syntax discussed above. I'll repen this issue and add a separate comment listing next steps.

  11. pekkaklarck commented on Aug 29, 2026

    @pekkaklarck
    Member

    As discussed above, we'll change the admonition syntax from Python-Markdown style to the style support by GitHub and others. Even though all tool don't support optional titles, I believe we should support them.

    One design decision to be made is that what HTML we should generate. I believe we should generate exactly the same HTML as Python-Markdown does for the following reasons:

    • It has worked well, I don't see needs to change it.
    • We already have styles for it, no need to change them.
    • No need to change tests that validate the generated HTML either (other than the source).

    The next steps to get the admonition syntax changed are:

    1. Implement a custom plugin that supports the new admonition syntax.
    2. Change standard library docs to use the new syntax.
    3. Remove support for the old syntax.
    4. Update tests and docs accordingly.
  12. pekkaklarck commented on Aug 30, 2026

    @pekkaklarck
    Member

    Now that we are switching to GFM style admonitions, we need to decide what admonition types we want to support.

    Our current approach is that any type is accepted when converting Markdown to HTM and the type is simply written to the generated HTML as a class attribute. Then there are dedicated styles for the following types:

    • note (blueish)
    • tip (greenish)
    • warning (yellowish)
    • danger (reddish)

    The above list of types was inspired by the types Material for MkDocs supports, but only contains a subset of those types. Other types than the above are formatted the same way as note.

    GFM, on the other hand, supports note tip, important, warning and caution, and all others are rendered as a blockquote:

    Note

    Useful information that users should know, even when skimming content.

    Tip

    Helpful advice for doing things better or more easily.

    Important

    Key information users need to know to achieve their goal.

    Warning

    Urgent info that needs immediate user attention to avoid problems.

    Caution

    Advises about risks or negative outcomes of certain actions.

    [!UNRECOGNIZED]
    Something.

    Because we are moving to the GFM style, I pretty strongly believe we should support all the same styles it does. Luckily we already support note, tip and warning, but we still need to decide how to handle important and caution. We also need to decide how to handle unrecognized styles and what to do with danger that we currently support. I propose we handle them like this:

    • important: I think we should give it its own purplish styles similarly as GFM has. Making it an alias for note or tip would probably be fine as well, though.
    • caution: We should simply give it the same styles danger currently has.
    • danger: I don't see much needs to support danger at all if we have caution. Let's remove it.
    • Unrecognized: Let's treat them like nowadays i.e. give them same styles as note. That simplifies parsing and makes it easier to add more types in the future if needed.

    Any opinions from others?

  13. pekkaklarck commented on Sep 1, 2026

    @pekkaklarck
    Member

    Admonition docs and styles have been updated so this issue can be closed again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions