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

manpages builder uses bold for entire options #10259

Open
CendioOssman opened this issue Mar 11, 2022 · 6 comments
Open

manpages builder uses bold for entire options #10259

CendioOssman opened this issue Mar 11, 2022 · 6 comments

Comments

@CendioOssman
Copy link

CendioOssman commented Mar 11, 2022

Describe the bug

Unfortunately the manpages writer doesn't follow the conventions of man pages when it generates the output for .. option:: directives. It makes the entire line bold, not just the literal parts.

How to Reproduce

Run this through the manpages builder:

.. option:: -p PROJECT, --project=PROJECT
   Project name will be set.

You'll get:

.B \-p PROJECT, \-\-project=PROJECT
Project name will be set.

Expected behavior

\fB\-p\fR \fIPROJECT\fR, \fB\-\-project\fR=\fIPROJECT\fR
Project name will be set.

Your project

N/A

Screenshots

No response

OS

Linux

Python version

3.6.12

Sphinx version

4.2.0

Sphinx extensions

No response

Extra tools

No response

Additional context

No response

@CendioOssman
Copy link
Author

It looks like this problem has two parts to it:

  1. The manpage writer handles the entire signature as a "term", ignoring any internal markup
  2. The option directive unfortunately doesn't parse things in much detail. The option itself becomes a desc_name, and everything else becomes desc_addname. It doesn't separate punctuation from identifiers.

@CendioOssman
Copy link
Author

I'm guessing the second point is resolved by #10366? @marxin?

@tk0miya
Copy link
Member

tk0miya commented Jul 3, 2022

This is generated doctree (w/ HEAD of 5.x branch)

        <desc classes="std option" desctype="option" domain="std" noindex="False" objtype="option">
            <desc_signature allnames="-p --project" classes="sig sig-object std sig sig-object" ids="cmdoption-p cmdoption-project">
                <desc_name classes="sig-name descname sig-name descname" xml:space="preserve">
                    -p
                <desc_addname classes="sig-prename descclassname sig-prename descclassname" xml:space="preserve">
                     PROJECT
                <desc_addname classes="sig-prename descclassname sig-prename descclassname" xml:space="preserve">
                    ,
                <desc_name classes="sig-name descname sig-name descname" xml:space="preserve">
                    --project
                <desc_addname classes="sig-prename descclassname sig-prename descclassname" xml:space="preserve">
                    =PROJECT
            <desc_content>
                <paragraph>
                    Project name will be set.

As you said, the option value is now parsed as a desc_addname node. But it's not good to render it as an italic text because desc_addname is also used for other purposes. For example, this is a doctree of py:class definition. In this case, it's used for the module name.

        <desc classes="py class" desctype="class" domain="py" noindex="False" objtype="class">
            <desc_signature class="" classes="sig sig-object py sig sig-object" fullname="Dummy" ids="example.Dummy" module="example">
                <desc_annotation xml:space="preserve">
                    class
                    <desc_sig_space classes="w w">


                <desc_addname classes="sig-prename descclassname sig-prename descclassname" xml:space="preserve">
                    example.
                <desc_name classes="sig-name descname sig-name descname" xml:space="preserve">
                    Dummy
                <desc_parameterlist xml:space="preserve">
                    <desc_parameter xml:space="preserve">
                        <desc_sig_name classes="n n">
                            arg

@CendioOssman
Copy link
Author

That looks like the same output as 4.2.0 is giving me. Was the new syntax from #10366 used in your test?

@marxin
Copy link
Contributor

marxin commented Jul 7, 2022

I see the following when using option_emphasise_placeholders = True:
Screenshot from 2022-07-07 11-04-38

where the first one is using it and the second one not:

.. option:: -foo={BAR}, -f {BAR} {BAZ}

  Using emphasising placeholders.

.. option:: -foo=BAR, -f BAR BAZ

   Normal option values.

@CendioOssman
Copy link
Author

Nice. Looks like the biggest issue is resolved then.

The = and , shouldn't be bold, but that's a minor issue compared to the placeholders.

@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
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

4 participants