From 471fbbdc8b496737591641ddb296b0e9d6c35b4f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 24 Apr 2023 07:28:50 +0100 Subject: [PATCH 1/2] Remove make_old_id functions --- sphinx/domains/c.py | 8 -------- sphinx/domains/javascript.py | 16 ---------------- sphinx/domains/python.py | 10 ---------- sphinx/domains/rst.py | 16 ---------------- sphinx/domains/std.py | 37 ------------------------------------ 5 files changed, 87 deletions(-) diff --git a/sphinx/domains/c.py b/sphinx/domains/c.py index 173db0b80c6..c583a770d13 100644 --- a/sphinx/domains/c.py +++ b/sphinx/domains/c.py @@ -3312,14 +3312,6 @@ def after_content(self) -> None: self.env.temp_data['c:parent_symbol'] = self.oldParentSymbol self.env.ref_context['c:parent_key'] = self.oldParentKey - def make_old_id(self, name: str) -> str: - """Generate old styled node_id for C objects. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return 'c.' + name - class CMemberObject(CObject): object_type = 'member' diff --git a/sphinx/domains/javascript.py b/sphinx/domains/javascript.py index 7f07c20b5ec..093e291ca57 100644 --- a/sphinx/domains/javascript.py +++ b/sphinx/domains/javascript.py @@ -207,14 +207,6 @@ def after_content(self) -> None: 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_') - def _toc_entry_name(self, sig_node: desc_signature) -> str: if not sig_node.get('_toc_parts'): return '' @@ -321,14 +313,6 @@ def run(self) -> list[Node]: ret.extend(content_node.children) 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, diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index edd4e829f0f..2fdd79e866e 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -1064,16 +1064,6 @@ def run(self) -> list[Node]: ret.extend(content_node.children) return ret - def make_old_id(self, name: str) -> str: - """Generate old styled node_id. - - Old styled node_id is incompatible with docutils' node_id. - It can contain dots and hyphens. - - .. note:: Old styled node_id was mainly used until Sphinx-3.0. - """ - return 'module-%s' % name - class PyCurrentModule(SphinxDirective): """ diff --git a/sphinx/domains/rst.py b/sphinx/domains/rst.py index 030d532cfd5..84a651231c5 100644 --- a/sphinx/domains/rst.py +++ b/sphinx/domains/rst.py @@ -52,14 +52,6 @@ def add_target_and_index(self, name: str, sig: str, signode: desc_signature) -> def get_index_text(self, objectname: str, name: str) -> str: return '' - def make_old_id(self, name: str) -> str: - """Generate old styled node_id for reST markups. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return self.objtype + '-' + name - def _object_hierarchy_parts(self, sig_node: desc_signature) -> tuple[str, ...]: if 'fullname' not in sig_node: return () @@ -193,14 +185,6 @@ def current_directive(self) -> str: else: return '' - def make_old_id(self, name: str) -> str: - """Generate old styled node_id for directive options. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return '-'.join([self.objtype, self.current_directive, name]) - class ReSTRole(ReSTMarkup): """ diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index d1a6b048fa9..786bbbc6cfb 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -72,14 +72,6 @@ def add_target_and_index(self, name: str, sig: str, signode: desc_signature) -> std = cast(StandardDomain, self.env.get_domain('std')) std.note_object(self.objtype, name, node_id, location=signode) - def make_old_id(self, name: str) -> str: - """Generate old styled node_id for generic objects. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return self.objtype + '-' + name - class EnvVar(GenericObject): indextemplate = _('environment variable; %s') @@ -144,14 +136,6 @@ def run(self) -> list[Node]: return ret - def make_old_id(self, name: str) -> str: - """Generate old styled node_id for targets. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return self.name + '-' + name - class Cmdoption(ObjectDescription[str]): """ @@ -228,11 +212,6 @@ def add_target_and_index(self, firstname: str, sig: str, signode: desc_signature node_id = make_id(self.env, self.state.document, prefix, optname) signode['ids'].append(node_id) - old_node_id = self.make_old_id(prefix, optname) - if old_node_id not in self.state.document.ids and \ - old_node_id not in signode['ids']: - signode['ids'].append(old_node_id) - self.state.document.note_explicit_target(signode) domain = cast(StandardDomain, self.env.get_domain('std')) @@ -249,14 +228,6 @@ def add_target_and_index(self, firstname: str, sig: str, signode: desc_signature entry = '; '.join([descr, option]) self.indexnode['entries'].append(('pair', entry, signode['ids'][0], '', None)) - def make_old_id(self, prefix: str, optname: str) -> str: - """Generate old styled node_id for cmdoption. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return nodes.make_id(prefix + '-' + optname) - class Program(SphinxDirective): """ @@ -515,14 +486,6 @@ def run(self) -> list[Node]: node.append(subnode) return [node] - def make_old_id(self, token: str) -> str: - """Generate old styled node_id for tokens. - - .. note:: Old Styled node_id was used until Sphinx-3.0. - This will be removed in Sphinx-5.0. - """ - return nodes.make_id('grammar-token-' + token) - class TokenXRefRole(XRefRole): def process_link(self, env: BuildEnvironment, refnode: Element, has_explicit_title: bool, From ba360d7111c1ab6732b18690b431f9c8aff2eddb Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 26 Apr 2023 17:32:36 +0100 Subject: [PATCH 2/2] CHANGES --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index bad68225c94..0b82096c27a 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,8 @@ Incompatible changes * #11359: Remove long-deprecated aliases for ``MecabSplitter`` and ``DefaultSplitter`` in ``sphinx.search.ja``. +* #11360: Remove deprecated ``make_old_id`` functions in domain object + description classes. Deprecated ----------