Skip to content

config's default output format might not render as expected #12960

Open

Description

@InSyncWithFoo

Currently, the output of a config command is something like this:

>>> subprocess.getoutput(['ruff', 'config', 'lint.preview'])
'Whether to enable preview mode. When preview mode is enabled, Ruff will\nuse unstable rules and fixes.\n\nDefault value: false\nType: bool\nExample usage:\n```toml\n# Enable preview features.\npreview = true\n```'

In the terminal, this looks nice:

Whether to enable preview mode. When preview mode is enabled, Ruff will
use unstable rules and fixes.

Default value: false
Type: bool
Example usage:
```toml
# Enable preview features.
preview = true
```

However, when rendered, the "Default value", "Type" and "Example usage" lines are collapsed into a single <p> (Commonmark dingus):

<p>Whether to enable preview mode. When preview mode is enabled, Ruff will
use unstable rules and fixes.</p>
<p>Default value: false
Type: bool
Example usage:</p>
<pre><code class="language-toml"># Enable preview features.
preview = true
</code></pre>

For example, here's how PyCharm renders it:

A possible fix is to append two spaces to the end of the first two lines in question (Commonmark dingus):

'...Default value: false  \nType: bool  \nExample usage:...'

Also, default values and types should be surrounded in backticks.

Activity

  1. Avasam commented on Aug 18, 2024

    @Avasam
    Contributor

    Note: Backslashes also work as markdown newline indicators (and are more obvious than double spaces) demo. But if the goal is to also display the same string in a terminal, then yeah two spaces is probably the best.

  2. changed the title [-]`config`'s default output format doesn't render very nicely[/-] [+]`config`'s default output format might not render as expected[/+] on Aug 18, 2024
  3. MichaReiser commented on Aug 18, 2024

    @MichaReiser
    Member

    Thanks for opening this issue. I agree, the output in PyCharm isn't ideal.

    I assume that the hover text in PyCharm comes from the JSON schema. If that's the case, I would prefer a local change in the schema generation to use \ over the somewhat obscure use of two spaces at the end of the line.

  4. added
    help wanted
    on Aug 18, 2024
  5. InSyncWithFoo commented on Aug 18, 2024

    @InSyncWithFoo
    ContributorAuthor

    It wasn't the schema (it would have been great if that was the case, though); I triggered the renderer semi-manually. (Yes, I could have asked for the JSON and put it together myself, too, but that's beside the point.)

    Submitting a PR.

  6. removed
    help wanted
    on Aug 18, 2024
  7. charliermarsh commented on Aug 18, 2024

    @charliermarsh
    Member

    @MichaReiser -- Is there still something to do here given the PR was closed?

  8. MichaReiser commented on Aug 19, 2024

    @MichaReiser
    Member

    ruff config only supports the output format text and json. The ask in this issue is to add a markdown output format.

  9. added
    wish
    on Aug 19, 2024
  10. InSyncWithFoo commented on Aug 21, 2024

    @InSyncWithFoo
    ContributorAuthor

    It turned out that the format wasn't as nice compared to other popups of the same kind, so I rendered it manually anyway. It took more efforts than I expected, but behold the result:

    I'll keep this issue open, though, since someone else might need it.

  11. MichaReiser commented on Aug 22, 2024

    @MichaReiser
    Member

    This looks great!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    wish

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions