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

Support myst-parser #127

Open
LecrisUT opened this issue Oct 10, 2023 · 3 comments
Open

Support myst-parser #127

LecrisUT opened this issue Oct 10, 2023 · 3 comments

Comments

@LecrisUT
Copy link

Currently the generated code is specific for rst documents such that the following does not work:

```{click} module:parser
:prog: hello-world
```

There is a workaround using:

```{eval-rst}
.. click:: [scikit_build_core.cli.main:skbuild](module:parser)
   :prog: hello-world
```

However it would be good to have built-in to use the appropriate parser (i.e. rst) for the generated code.

@stephenfin
Copy link
Member

fwiw, I looked at this today. It seems myst_parser does not seem to be happy with our use of sphinx.utils.nodes.nested_parse_with_titles. That should return a load of docutils nodes but the output is off.

Here's an example using reStructuredText:

Screen Shot 2024-04-06 at 10 28 29

and here's the equivalent using Markdown:

Screen Shot 2024-04-06 at 10 28 17

You can see that all the directives are outputted in raw form rather than being processed and nested as expected. I'm not sure how you'd go about fixing this, tbh.

@stephenfin
Copy link
Member

If anyone is interested in fixing this, there's a minimal reproducer here.

@LecrisUT
Copy link
Author

LecrisUT commented Apr 7, 2024

Yes, and I think that's expected, I've used something similar when messing around with autodoc extensions. For that case, it was fine because the nature of the docstring (rst or md fomat) is known by the user, amd they could fine-tune and select the appropriate parser with eval-rst.

The issue here are:

  • the generated doc fragments do not account for which parser it is currently in, e.g.
    yield '.. program:: {}'.format(ctx.command_path)

    This could have an if statement to generate either format. It should be within an with to appropriately start-end the blocks
  • the api is monolithic, but something along the lines of sphinx autodoc would probably be more manageable

I think the only relevant references here is sphinx-autodoc2, e.g. see their approach here (navigate to the concrete implementations for myst and rst)

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

No branches or pull requests

2 participants