-
Notifications
You must be signed in to change notification settings - Fork 47
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 #184 from dhellmann/inline-directive
feature: domain and role
- Loading branch information
Showing
10 changed files
with
171 additions
and
22 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
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,4 +1,4 @@ | ||
.. spelling:: | ||
.. spelling:word-list:: | ||
sphinxcontrib | ||
reStructuredText | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.. spelling:: | ||
.. spelling:word-list:: | ||
sphinxcontrib | ||
|
||
|
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,4 +1,4 @@ | ||
.. spelling:: | ||
.. spelling:word-list:: | ||
sphinxcontrib | ||
|
||
|
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,30 @@ | ||
from docutils import nodes | ||
from sphinx.domains import Domain | ||
|
||
from . import directive, role | ||
|
||
|
||
class SpellingDomain(Domain): | ||
|
||
name = 'spelling' | ||
label = 'Spelling Checker' | ||
directives = { | ||
'word-list': directive.SpellingDirective, | ||
} | ||
roles = { | ||
'word': role.WordRole('spelling:word', nodes.Text), | ||
} | ||
|
||
def get_objects(self): | ||
return [] | ||
|
||
def resolve_xref(self, env, fromdocname, builder, typ, target, node, | ||
contnode): | ||
return None | ||
|
||
def resolve_any_xref(self, env, fromdocname, builder, target, node, | ||
contnode): | ||
return [] | ||
|
||
def merge_domaindata(self, docnames, otherdata): | ||
pass |
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,17 @@ | ||
from docutils.parsers.rst import roles | ||
|
||
from . import directive | ||
|
||
|
||
class WordRole(roles.GenericRole): | ||
"""Let the user indicate that inline text is spelled correctly. | ||
""" | ||
|
||
def __call__(self, role, rawtext, text, lineno, inliner, | ||
options={}, content=[]): | ||
env = inliner.document.settings.env | ||
docname = env.docname | ||
good_words = text.split() | ||
directive.add_good_words_to_document(env, docname, good_words) | ||
return super().__call__(role, rawtext, text, lineno, inliner, | ||
options=options, content=content) |
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