Skip to content

Commit

Permalink
Close sphinx-doc#267: html: Eliminate prompt characters of doctest bl…
Browse files Browse the repository at this point in the history
…ock from copyable text
  • Loading branch information
tk0miya committed Oct 10, 2019
1 parent d6334e7 commit 6b9e0cb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Features added
--------------

* #6707: C++, support bit-fields.
* #267: html: Eliminate prompt characters of doctest block from copyable text

Bugs fixed
----------
Expand Down
4 changes: 4 additions & 0 deletions sphinx/themes/basic/static/basic.css_t
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,10 @@ div.code-block-caption + div > div.highlight > pre {
margin-top: 0;
}

div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
user-select: none;
}

div.code-block-caption span.caption-number {
padding: 0.1em 0.3em;
font-style: italic;
Expand Down
11 changes: 11 additions & 0 deletions sphinx/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,16 @@ def apply(self, **kwargs):
location=node)


class DoctestTransform(SphinxTransform):
"""Set "doctest" style to each doctest_block node"""
default_priority = 500

def apply(self, **kwargs):
# type: (Any) -> None
for node in self.document.traverse(nodes.doctest_block):
node['classes'].append('doctest')


class FigureAligner(SphinxTransform):
"""
Align figures to center by default.
Expand Down Expand Up @@ -425,6 +435,7 @@ def setup(app):
app.add_transform(MoveModuleTargets)
app.add_transform(HandleCodeBlocks)
app.add_transform(SortIds)
app.add_transform(DoctestTransform)
app.add_transform(FigureAligner)
app.add_transform(AutoNumbering)
app.add_transform(AutoIndexUpgrader)
Expand Down

0 comments on commit 6b9e0cb

Please sign in to comment.