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
Fix bug of Sphinx's .. code:: directive not recognizing :class: option #9688
Fix bug of Sphinx's .. code:: directive not recognizing :class: option #9688
Conversation
Thanks for the PR @latosha-maltba ! Looks like it has conflicts though. Perhaps you branched off |
b7b36a2
to
eed1085
Compare
Hi, @astrojuanlu
Not quite, there was just some other pull request merged and that lead to a conflict in CHANGES as is to expect when documenting the changelog in a monolithic file. |
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.
Could you call docutils.parsers.rst.roles.set_classes()
before accessing self.options['classes']
? It's a well-known technique to implement directives on docutils. This is a bug that the code directive does not call the helper function before accessing the option. You can see examples under the docutils.parsers.rst.directives package.
CHANGES
Outdated
@@ -41,6 +41,7 @@ Bugs fixed | |||
* #9649: HTML search: when objects have the same name but in different domains, | |||
return all of them as result instead of just one. | |||
* #9678: linkcheck: file extension was shown twice in warnings | |||
* Fix bug ``.. code::`` not recognising ``:classes:`` option instead of ``:class:`` option. The new behaviour is only to accept ``:class:``. |
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.
This is not correct. The code
directive does not recognize the :classes:
option. Simply, it ignores given :class:
option.
Sphinx's own .. code:: directive (but not docutils') does not recognise the :class: option but only the :classes: option. This is probably due to an oversight that the user-visible option is called ``:class:`` while the Python attribute is called ``classes`` (to not collide with the keyword ``class``). Fix it by checking for the option ``class`` instead of ``classes``.
eed1085
to
9c53175
Compare
Been there, done that. |
Merged! Thank you for your work :-) |
Subject: Fix bug of Sphinx's .. code:: directive not recognizing :class: option
Feature or Bugfix
Purpose
Sphinx's own .. code:: directive (but not docutils') does not recognise
the :class: option but only the :classes: option. This is probably due
to an oversight that the user-visible option is called
:class:
whilethe Python attribute is called
classes
(to not collide with thekeyword
class
).Fix it by checking for the option
class
instead ofclasses
.Remark: Theoretically, someone could depend on
classes
beingrecognised by Sphinx's
.. code::
directive. However, I highlydoubt that because:
a)
class
is the canonical and documented way to add classesb)
classes
was never documented by Sphinx.c) Sphinx encourages
.. code-block::
over.. code::
.