This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from docascode/yitian/add-remarks-directive
add remarks directive
- Loading branch information
Showing
7 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# coding: utf-8 | ||
|
||
""" | ||
This module is used to add extra supported directives to sphinx. | ||
""" | ||
|
||
from docutils.parsers.rst import Directive | ||
from docutils import nodes | ||
|
||
from .nodes import remarks | ||
|
||
class RemarksDirective(Directive): | ||
""" | ||
Class to enable remarks directive. | ||
""" | ||
|
||
# Enable content in the directive | ||
has_content = True | ||
|
||
# Directive class must override run function. | ||
def run(self): | ||
self.assert_has_content() | ||
|
||
text = '\n'.join(self.content) | ||
|
||
return_nodes = [] | ||
|
||
node = remarks('', text) | ||
return_nodes.append(node) | ||
|
||
return return_nodes |
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
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# coding: utf-8 | ||
|
||
""" | ||
This module is used to add extra supported nodes to sphinx. | ||
""" | ||
|
||
from docutils import nodes | ||
|
||
class remarks(nodes.paragraph): | ||
""" | ||
New node for remarks messages. | ||
""" | ||
|
||
@staticmethod | ||
def visit_remarks(self, node): | ||
self.visit_paragraph(node) | ||
|
||
@staticmethod | ||
def depart_remarks(self, node): | ||
self.depart_paragraph(node) |
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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
Docstring from __init__.py | ||
""" |
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