-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
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! |
@@ -174,6 +174,31 @@ class desc_content(nodes.General, nodes.Element): | |||
""" | |||
|
|||
|
|||
class desc_sig_element(nodes.inline): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea...
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea...
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.