Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI
on: push
on: [push, pull_request]

env:
JRUBY_OPTS: -Xcext.enabled=true
Expand Down
31 changes: 30 additions & 1 deletion lib/github/commands/rest2html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ except:
import codecs
import io

from docutils import nodes
from docutils import nodes, utils
from docutils.parsers.rst import directives, roles
from docutils.parsers.rst.directives.body import CodeBlock, Directive
from docutils.core import publish_parts
Expand Down Expand Up @@ -76,6 +76,35 @@ from docutils import nodes
original_behavior = False # Documents original docutils behavior
github_display = True

def extract_extension_options(field_list, option_spec):
"""
Overrides `utils.extract_extension_options` and inlines
`utils.assemble_option_dict` to make it ignore unknown options passed to
directives (i.e. ``:caption:`` for ``.. code-block:``).
"""

dropped = set()
options = {}
for name, value in utils.extract_options(field_list):
convertor = option_spec.get(name)
if name in options or name in dropped:
raise utils.DuplicateOptionError('duplicate option "%s"' % name)

# silently drop unknown options as long as they are not duplicates
if convertor is None:
dropped.add(name)
continue

# continue as before
try:
options[name] = convertor(value)
except (ValueError, TypeError) as detail:
raise detail.__class__('(option: "%s"; value: %r)\n%s'
% (name, value, ' '.join(detail.args)))
return options

utils.extract_extension_options = extract_extension_options

def unknown_directive(self, type_name):
lineno = self.state_machine.abs_line_number()
indented, indent, offset, blank_finish = \
Expand Down
6 changes: 6 additions & 0 deletions test/markups/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ The UTF-8 quote character in this table used to cause python to go boom. Now doc

python.code('hooray')

.. code:: python
:caption: An ignored Sphinx option
:made-up-option: An ignored made up option

python.code('hello world')

.. doctest:: ignored

>>> some_function()
Expand Down
3 changes: 3 additions & 0 deletions test/markups/README.rst.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ <h2><a href="#id1">Header 2</a></h2>
python.code('hooray')
</pre>
<pre lang="python">
python.code('hello world')
</pre>
<pre lang="python">
&gt;&gt;&gt; some_function()
'result'
</pre>
Expand Down