diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-01-18 02:12:30 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-01-18 02:12:30 +0100 |
commit | 6e3827f3da4428e68a31bf9eb94f3b48fc643aa4 (patch) | |
tree | 986255cef78e9b7d2dbdcce66a596c9075ab8007 /exts | |
parent | 2f6b4cce4019c9c82666692e4d86ca8076bc0641 (diff) | |
download | docs-6e3827f3da4428e68a31bf9eb94f3b48fc643aa4.tar.gz docs-6e3827f3da4428e68a31bf9eb94f3b48fc643aa4.tar.bz2 docs-6e3827f3da4428e68a31bf9eb94f3b48fc643aa4.zip |
Clarifications and formatting
Diffstat (limited to 'exts')
-rw-r--r-- | exts/tsref.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/exts/tsref.py b/exts/tsref.py index 68f94c27..03575d31 100644 --- a/exts/tsref.py +++ b/exts/tsref.py @@ -14,9 +14,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. """ -This extension adds a new lexer "tsref", which +This extension adds a new lexer "tsref" for TypeScript, which allows reST-style links inside comments (`LinkName`_), -and semi-automatically adds links to references to types. +and semi-automatically adds links to the definition of types. For type TYPE, a reference to tsref-type-TYPE is added. @@ -62,8 +62,6 @@ class LinkingHtmlFormatter(HtmlFormatter): return value return '<span class="%s">%s</span>' % (cls, value) - - def _format_lines(self, tokensource): """ Just format the tokens, without any wrapping tags. @@ -95,7 +93,6 @@ class LinkingHtmlFormatter(HtmlFormatter): yield 1, line + lsep - class MyPygmentsBridge(PygmentsBridge): def __init__(self, builder, trim_doctest_flags): self.dest = "html" @@ -125,6 +122,7 @@ def get_annotation(tok, key): return None return tok.kv.get(key) + def copy_token(tok): new_tok = _TokenType(tok) # This part is very fragile against API changes ... @@ -132,6 +130,7 @@ def copy_token(tok): new_tok.parent = tok.parent return new_tok + def tok_setprop(tok, key, value): tokid = id(tok) e = token_props.get(tokid) @@ -140,6 +139,7 @@ def tok_setprop(tok, key, value): _, kv = e kv[key] = value + def tok_getprop(tok, key): tokid = id(tok) e = token_props.get(tokid) @@ -151,9 +151,13 @@ def tok_getprop(tok, key): link_reg = re.compile(r"`([^`]+)`_") -# map from token id to props +# Map from token id to props. +# Properties can't be added to tokens +# since they derive from Python's tuple. token_props = {} +# Mapping from element IDs to document +# name where the ID occurs. id_to_doc = {} |