Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
docs: (Sphinx) fixing limitation code
Also cleanup of latex-scan.py.
- Loading branch information
1 parent
cd2ced3
commit f39eb38
Showing
2 changed files
with
34 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 18 additions & 34 deletions
52
docs/manuals/en/new_main_reference/source/extensions/limitation.py
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from docutils import nodes | ||
from docutils.parsers.rst import Directive | ||
from docutils.parsers.rst import directives | ||
#from sphinx.util.docutils import SphinxDirective | ||
|
||
class Limitation(nodes.Structural, nodes.Element): | ||
pass | ||
|
||
class LimitationDirective(Directive): | ||
class Limitation(Directive): | ||
|
||
# Define the parameters the directive expects | ||
required_arguments = 0 | ||
required_arguments = 1 | ||
optional_arguments = 0 | ||
|
||
# A boolean, indicating if the final argument may contain whitespace | ||
final_argument_whitespace = True | ||
option_spec = {'title', } | ||
#option_spec = {'title', } | ||
has_content = True | ||
|
||
def run(self): | ||
# Raise an error if the directive does not have contents. | ||
sett = self.state.document.settings | ||
env = self.state.document.settings.env | ||
|
||
config = env.config | ||
|
||
# Raise an error if the directive does not have contents. | ||
self.assert_has_content() | ||
text = '\n'.join(self.content) | ||
|
||
# Get access to the options of directive | ||
options = self.options | ||
|
||
# Create the limitation content, to be populated by `nested_parse`. | ||
limitation_content = nodes.paragraph(rawsource=text) | ||
|
||
# Parse the directive contents. | ||
self.state.nested_parse(self.content, self.content_offset, limitation_content) | ||
|
||
# Create a title | ||
limitation_title = nodes.title("Limitations: " + options["title"]) | ||
|
||
# Create the limitation node | ||
node = Limitation() | ||
node += limitation_title | ||
node += limitation_content | ||
title = 'Limitation: ' + self.arguments[0] | ||
text = '\n'.join(self.content) | ||
|
||
# Return the result | ||
return [node] | ||
paragraph = nodes.paragraph() | ||
self.state.nested_parse(self.content, self.content_offset, paragraph) | ||
|
||
#class Limitation(LimitationDirective): | ||
# pass | ||
result = nodes.section(ids=['limitation']) | ||
result += nodes.title(text=title) | ||
#result += nodes.paragraph(text=text) | ||
result += paragraph | ||
return [result] | ||
|
||
def setup(app): | ||
app.add_node(Limitation) | ||
app.add_directive("limitation", LimitationDirective) | ||
directives.register_directive("limitation", Limitation) |