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

Rewrite MD to RST in TypeScript #2866

Open
lmazuel opened this issue Oct 10, 2024 · 1 comment
Open

Rewrite MD to RST in TypeScript #2866

lmazuel opened this issue Oct 10, 2024 · 1 comment
Assignees

Comments

@lmazuel
Copy link
Member

lmazuel commented Oct 10, 2024

Swagger and TypeSpec both have all description string written in Markdown. In Pythonn, docstring are expected to be written in RST. In order to get our doc processor to generate valid documentation, it's important that we convert the MD syntax into RST syntax.

For example, this code in MD:

# Example Title

This is an example paragraph in **Markdown**. You can include _italicized text_ and **bold text**. Here's a link to [Microsoft's website](https://www.microsoft.com).

should be written in SDK in RST as:

Example Title
=============

This is an example paragraph in **reStructuredText**. You can include *italicized text* and **bold text**. Here's a link to `Microsoft's website <https://www.microsoft.com>`_.

We're doing this conversion today using m2r which is a Python library. There are a few problems with it:

  • It requires dependencies, and those are non trivial to support
  • It's buggy, and we got issue in the past
  • It's slow (we don't have the metrics, but I know it's slow :))

Work is to rewrite it in TypeScript. IOW, create a function like:

function mdToRst(input: string): string {
    // You can add any processing logic here
    return `Processed string: ${input}`;
}

Expectation of that works includes finding the unittests, investigate what exists today in TypeSpec and Swagger (ideally as a bulk, Swagger can be investigate by parsing them as JSON, Typespec can be investigate by generating the Swagger first), plug it in the codegen, and run tests across many SDKs to look for diff.

A few notes:

  • It's likely necessary to write this manually (I would be surprised the TypeScript world has a tool for that), but if a tool exist it's ok to start with that
  • It's probably unecessary anyway to support the entire set of MD syntax. Investigation can tell us how much work we need, and maybe a few lines of regexp replace are enough.
  • There are MD parser in TypeScript, it's likely a good idea to start with that and build a renderer

Estimated cost: 3 weeks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants