Currently there are very few options for styling declarations, essentially only a few desc_* nodes in sphinx/addnodes.py. For some languages (e.g., C++) declarations may contain many keywords and built-in types that should be coloured to help readability. It would be cool if themes could define custom styles.
I'm not sure what the best way to go about this is, but how about the following.
From Pygments (pygments.tokens) I found the following types of tokens:
'Comment', 'Error', 'Escape', 'Generic', 'Keyword', 'Literal', 'Name', 'Number', 'Operator', 'Other', 'Punctuation', 'STANDARD_TYPES', 'String', 'Text', 'Token', 'Whitespace'
To addnodes.py we could add additional desc_* nodes for those we don't have yet, and that makes sense. Each should be constructible with a domain name. In terms of CSS each of them should emit two classes; a generic one and a domain-specific one (if a domain is specified).
- Can this be done in a format-agnostic way with Docutils? (via the
classes attribute?)
- Can we make the nodes inherit from a common class so writers can opt-in to support this?
- As this overlaps a lot with Pygments, is there anything we can reuse? E.g., the style maps?
- Is there a better way to implement this?
- Are people against this feature?
Currently there are very few options for styling declarations, essentially only a few
desc_*nodes insphinx/addnodes.py. For some languages (e.g., C++) declarations may contain many keywords and built-in types that should be coloured to help readability. It would be cool if themes could define custom styles.I'm not sure what the best way to go about this is, but how about the following.
From Pygments (
pygments.tokens) I found the following types of tokens:'Comment', 'Error', 'Escape', 'Generic', 'Keyword', 'Literal', 'Name', 'Number', 'Operator', 'Other', 'Punctuation', 'STANDARD_TYPES', 'String', 'Text', 'Token', 'Whitespace'
To
addnodes.pywe could add additionaldesc_*nodes for those we don't have yet, and that makes sense. Each should be constructible with a domain name. In terms of CSS each of them should emit two classes; a generic one and a domain-specific one (if a domain is specified).classesattribute?)