py domain: Allow to make a style for arguments of functions and methods - #6990
Conversation
40c828d to
485e881
Compare
485e881 to
b2c431b
Compare
8e7484c to
03bdb25
Compare
|
Would it make sense to wrap each argument in an element? Something like: def join(*items: List, delimiter: str = ''):<span class="argument">
<span class="argument-sigil">*</span><span class="argument-name">items</span>
: <span class="annotation">List</span>
</span>,
<span class="argument">
<span class="argument-name">delimiter</span>
: <span class="annotation">str</span>
= <span class="default-value">''</span>
</span>This way, you could apply CSS to the entire argument, e.g. to prefer line breaks between arguments rather than within them. |
|
Now HTML writer use |
|
Unfortunately I have not had time to take a closer look at this, so the following may be redundant. |
1f1b7d5 to
a44d6f9
Compare
|
I reviewed the doctree structure. I think it is enough to use the |
|
It would be neat if sphinx could parse a type annotation like |
It is better to surround these element by domain-classed element. It helps to choose individual element by CSS selector like |
Good point, and nice solution. That probably also minimizes the size of the output. |
a44d6f9 to
9906a18
Compare
9906a18 to
3eabd86
Compare
|
I think some discussion points are still remained.
To concentrate these points, I'm going to make another PR for signature parser based on this PR. I think it makes this PR simple. |
3eabd86 to
343bc8e
Compare
343bc8e to
19feb1b
Compare
2f40dda to
5dabbf9
Compare
|
Just updated. ready for review now! |
| """ | ||
|
|
||
|
|
||
| class desc_sig_element(nodes.inline): |
There was a problem hiding this comment.
I added desc_sig_element and children to realize pygments based inline text decorator (see #4289).
But I also added SigElementFallbackTransform to support old translators. It helps to render these nodes as simple inline node in old translators.
It means this does not break compatibility! I confirmed working fine with docxbuilder on my local.
| else: | ||
| node += nodes.Text('=' + str(param.default)) | ||
| node += addnodes.desc_sig_operator('', '=') | ||
| node += nodes.inline('', param.default, classes=['default_value']) |
There was a problem hiding this comment.
I can't find proper toke name from pygments. So I used inline node for default value. Is there good idea?
https://github.com/pygments/pygments/blob/master/pygments/token.py
5dabbf9 to
c3cc0d5
Compare
|
Is there any comments? If none, I'll merge this soon. The feature freeze period for 3.x will come soon. |
| else: | ||
| node += nodes.Text('=' + str(param.default)) | ||
| node += addnodes.desc_sig_operator('', '=') | ||
| node += nodes.inline('', param.default, classes=['default_value']) |
99a7386 to
fa95257
Compare
fa95257 to
50cf68e
Compare
|
Merged. Thank you for reviewing! |
Feature or Bugfix
Purpose
This adds new dependency:cached-property. So I'll merge this into master branch.Remaining tasks
documentationadditional nodes is needed?=> No.