Remove redundant directive name check causing case-sensitivity issue #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Found directive name matching issue in this package when trying to build
silverrainz.github.io
to validate some subtle changes QaQProblem
Error log:
full log:
Analysis and Solution
I found the directive name in runtime could be
'Contents'
, but the config from the blog is'contents'
, resulting mode being resolved asNone
and raising the error. (I did not investigate why the directive name is'Contents'
instead of'contents'
, it looks like Sphinx is normalizing directive name to capital case?)At the first look we could update the mock_directives to be
'Contents'
(with uppercaseC
) in https://github.com/SilverRainZ/silverrainz.github.io/blob/cf5fcad88b7727871af06c06f0d39ffda51a5606/conf.py#L207.However according to reST spec:
We could make the logic in sphinxnotes/mock case-insensitive to avoid such issues in the future.
Another fix is making the directive name matching in
MockDirective
case-insensive:mock/src/sphinxnotes/mock/__init__.py
Line 37 in 5692302
I found it is redundant to check directive name in
MockDirective
sinceapp.add_directive(name, cls, ...)
already binds a directive name to the given directive class.Finally, I elimated the redundant directive name checks in
MockDirective
class and updated the arguments forapp.add_directive()
to make Sphinx handle the directive name matching for us.Additional Changes