diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-03-01 02:10:46 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-03-01 02:10:46 +0900 |
commit | 0ef797ff65576d8c0e08120b60be3a2b961b8f81 (patch) | |
tree | 791b7dd239d7ae19be0bab335c86bed56f8834a7 /sphinx/domains/javascript.py | |
parent | 201455900a5fe938a1aadb4af37a2b13aeaa44bd (diff) | |
download | sphinx-git-0ef797ff65576d8c0e08120b60be3a2b961b8f81.tar.gz |
refactor: js domain: Change make_old_*_id() to methods
Diffstat (limited to 'sphinx/domains/javascript.py')
-rw-r--r-- | sphinx/domains/javascript.py | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/sphinx/domains/javascript.py b/sphinx/domains/javascript.py index d7e44ee60..d510d7903 100644 --- a/sphinx/domains/javascript.py +++ b/sphinx/domains/javascript.py @@ -34,24 +34,6 @@ from sphinx.util.nodes import make_id, make_refnode logger = logging.getLogger(__name__) -def make_old_jsmod_id(modname: str) -> str: - """Generate old styled node_id for JS modules. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return 'module-' + modname - - -def make_old_jsobj_id(fullname: str) -> str: - """Generate old styled node_id for JS objects. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return fullname.replace('$', '_S_') - - class JSObject(ObjectDescription): """ Description of a JavaScript object. @@ -129,7 +111,7 @@ class JSObject(ObjectDescription): # Assign old styled node_id not to break old hyperlinks (if possible) # Note: Will be removed in Sphinx-5.0 (RemovedInSphinx50Warning) - old_node_id = make_old_jsobj_id(fullname) + old_node_id = self.make_old_id(fullname) if old_node_id not in self.state.document.ids and old_node_id not in signode['ids']: signode['ids'].append(old_node_id) @@ -211,6 +193,14 @@ class JSObject(ObjectDescription): self.env.ref_context['js:object'] = (objects[-1] if len(objects) > 0 else None) + def make_old_id(self, fullname: str) -> str: + """Generate old styled node_id for JS objects. + + .. note:: Old Styled node_id was used until Sphinx-3.0. + This will be removed in Sphinx-5.0. + """ + return fullname.replace('$', '_S_') + class JSCallable(JSObject): """Description of a JavaScript function, method or constructor.""" @@ -282,7 +272,7 @@ class JSModule(SphinxDirective): # Assign old styled node_id not to break old hyperlinks (if possible) # Note: Will be removed in Sphinx-5.0 (RemovedInSphinx50Warning) - old_node_id = make_old_jsmod_id(mod_name) + old_node_id = self.make_old_id(mod_name) if old_node_id not in self.state.document.ids and old_node_id not in target['ids']: target['ids'].append(old_node_id) @@ -293,6 +283,14 @@ class JSModule(SphinxDirective): ret.append(inode) return ret + def make_old_id(self, modname: str) -> str: + """Generate old styled node_id for JS modules. + + .. note:: Old Styled node_id was used until Sphinx-3.0. + This will be removed in Sphinx-5.0. + """ + return 'module-' + modname + class JSXRefRole(XRefRole): def process_link(self, env: BuildEnvironment, refnode: Element, |