Skip to content

Commit

Permalink
Merge pull request #6727 from tk0miya/267_doctest_prompt_not_copyable
Browse files Browse the repository at this point in the history
Close #267: html: Eliminate prompt characters of doctest block from c…
  • Loading branch information
tk0miya committed Oct 13, 2019
2 parents 2d609dd + 6b9e0cb commit e3d3de7
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 @@ -269,6 +269,16 @@ def apply(self, **kwargs) -> None:
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 @@ -402,6 +412,7 @@ def setup(app: "Sphinx") -> Dict[str, Any]:
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 e3d3de7

Please sign in to comment.