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

Notes from first use of the CLI #11

Open
8 of 18 tasks
consideRatio opened this issue Jan 4, 2021 · 12 comments
Open
8 of 18 tasks

Notes from first use of the CLI #11

consideRatio opened this issue Jan 4, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@consideRatio
Copy link

consideRatio commented Jan 4, 2021

These are notes from converting the documentation of the https://github.com/jupyterhub/zero-to-jupyterhub-k8s project. I just wrote that came to mind along as I used it for the first time with no prior knowledge other than its a cli to help me transform rst to myst.

  • roles list command output line separated roles instead of a big string for better human readability.
  • roles show help string sais the same as list.
  • directives list/show same as above
  • --help could perhaps say something more relevant than CLI for rst-to-myst, such as the focus of its purpose.
    Usage: rst2myst [OPTIONS] COMMAND [ARGS]...
    
    CLI for rst-to-myst
    
  • parse --help or the help of the parse --conversion flag could perhaps provide some reference or be a bit more verbal about it maybe.
  • parse --extensions help text doesn't describe how to specify the extensions, comma separated list to load?
  • `parse --sphinx/--no-sphinx doesn't make it clear what is the default
  • Trailing blank lines.
    • The conversion of a .rst file with only hello world followed by a blank line leads to a .md output of hello world with 3 blank lines
    • The conversion of the following
      .. image:: ../_static/images/architecture.png
         :align: center
      
      Led to a blank new line in the image directive
      ```{image} ../_static/images/architecture.png
      :align: center
      
      ```
      
  • I noted that my generated myst directives was using colon-syntax for directives like note, and important, but not for code-block. I ended up with a mix of colon-syntax and backtick syntax for my myst directives. I had not enabled colon-syntax manually in any way or by configuration.
  • It would be nice to have a --validate flag or similar for a parsing, giving hints about the transform rather than just outputting the output without warnings etc.
  • I found myself using rst2myst parse -f myfile.rst > myfile.md a lot, it could be nice to have some flag to modify the file in place or similar perhaps. -i, --in-place for example.
  • I learned that it wasn't possible to do rst2myst parse -f test.md > test.md for some reason I don't get. I would guess this would be reasonable to have working in general though, for example cat test.md | sed replacesomething > test.md. Perhaps its because we started printing content before we had finished reading it?
  • Having used some double ticks in rst translated to doubleticks in md where I expected to have only one
  • I'm surprised to see this conversion of links...
    # rst
    `Google <https://cloud.google.com/>`_)
    
    # myst - why is there a <> remaining? It seems fine though.
    [Google](<https://cloud.google.com/>)
    
  • I failed to transform the glossary directive to myst, but the automated generated MyST content containing a eval-rst block worked.
  • Converting a .. toctree:: directive with a :titlesonly: argument worked in a way, but the generated MyST content was invalid. It became :titlesonly: None which made a difference to the toctree where nothing was shown instead of only the titles.
@consideRatio consideRatio added the enhancement New feature or request label Jan 4, 2021
@welcome
Copy link

welcome bot commented Jan 4, 2021

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@chrisjsewell
Copy link
Member

Thanks @consideRatio

I noted that ::: as a directive signal was used an directive that wasn't supported it seems, but was used for a directive that was. That made me a bit confused.

Can you expand on this a bit further, what directives are you referring to?

@consideRatio
Copy link
Author

consideRatio commented Jan 4, 2021

@chrisjsewell I updated the issue! I'm still adding to it btw, just didn't dare keep it in browser-memory without pressing send in between as a save mechanism :p

I noted that my generated myst directives was using colon-syntax for directives like note, and important, but not for code-block. I ended up with a mix of colon-syntax and backtick syntax for my myst directives. I had not enabled colon-syntax manually in any way or by configuration.

@chrisjsewell
Copy link
Member

I found myself using rst2myst parse -f myfile.rst > myfile.md a lot, it could be nice to have some flag to modify the file in place or similar perhaps. -i, --in-place for example.

related to #6

@chrisjsewell
Copy link
Member

Ha yeh no problem

@chrisjsewell
Copy link
Member

I noted that my generated myst directives was using colon-syntax for directives like note, and important, but not for code-block. I ended up with a mix of colon-syntax and backtick syntax for my myst directives. I had not enabled colon-syntax manually in any way or by configuration.

As talked about at https://github.com/executablebooks/rst-to-myst#advanced-usage, the conversion of directives is dictated by https://github.com/executablebooks/rst-to-myst/blob/main/rst_to_myst/data/directives.yml.
You can "update" this configuration with the --conversion my_config.yml, or I could add a flag to ignore the colon prefixes.

The idea though is that for directives that contain content that itself is Markdown, it is more helpful in standard renderers (like here on GitHub or viewing Jupyter Notebooks) to see:

:::{note}

This contains Markdown

:::

rather than

> This contains *Markdown*
- With things like [links](https://example.com)

for code-blocks, the content is not Markdown, so then we want ```

In fact, while I'm thinking it now, it would be ideal to have a special case for code/code-block directives, with no options, to convert them to standard language fences, i.e.

.. code-block:: python

   a = "text"

to:

```python
a = "text"
```

rather than

```{code-block} python
a = "text"
```

@chrisjsewell
Copy link
Member

myst - why is there a <> remaining? It seems fine though.

See hukkin/mdformat#38 (comment), i.e. its "safer", but could be removed with some extra code to check for unsafe links: hukkin/mdformat@a3b4de3

@chrisjsewell
Copy link
Member

I learned that it wasn't possible to do rst2myst parse -f test.md > test.md for some reason I don't get. I would guess this would be reasonable to have working in general though, for example cat test.md | sed replacesomething > test.md. Perhaps its because we started printing content before we had finished reading it?

Probably to do with the use of https://click.palletsprojects.com/en/7.x/api/#click.File, i.e. the file is still open

@chrisjsewell
Copy link
Member

Converting a .. toctree:: directive with a :titlesonly: argument worked in a way, but the generated MyST content was invalid. It became :titlesonly: None which made a difference to the toctree where nothing was shown instead of only the titles

as of v0.1.2, flags (i.e. options with no value) are converted to :key: true which should now work correctly

@chrisjsewell
Copy link
Member

parse --extensions help text doesn't describe how to specify the extensions, comma separated list to load?

no at present it would be parse -e ext1 -e ext2 -e ext3, but could do comma separated and also want to add #7

@chrisjsewell
Copy link
Member

A lot of this is now fixed in v0.2.0, see https://rst-to-myst.readthedocs.io/

whenever you have time, if you want to check it out and note any outstanding issues

@cjolowicz
Copy link

@consideRatio

I learned that it wasn't possible to do rst2myst parse -f test.md > test.md for some reason I don't get. I would guess this would be reasonable to have working in general though, for example cat test.md | sed replacesomething > test.md. Perhaps its because we started printing content before we had finished reading it?

This is a common shell gotcha. The shell truncates the output file when opening for writing, before the command has a chance to open it for reading.

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

No branches or pull requests

3 participants