From: Kefu Chai Date: Mon, 10 May 2021 03:56:54 +0000 (+0800) Subject: doc/_ext: define a helper for current_module() X-Git-Tag: v17.1.0~1986^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=44e611ce309cbc80ba78dbe564c738d03e193f4e;p=ceph.git doc/_ext: define a helper for current_module() less repeating this way, this change also addresses the missing option issue if the option to be rendered is the first option in a document, and there is no "mgr_module" directive before it. Signed-off-by: Kefu Chai --- diff --git a/doc/_ext/ceph_confval.py b/doc/_ext/ceph_confval.py index 44ef0bbf3faa..ffe036a6b93f 100644 --- a/doc/_ext/ceph_confval.py +++ b/doc/_ext/ceph_confval.py @@ -339,8 +339,12 @@ class CephOption(ObjectDescription): CephOption.mgr_opts[module] = dict((opt['name'], opt) for opt in opts) return CephOption.mgr_opts[module] + def _current_module(self) -> str: + return self.options.get('module', + self.env.ref_context.get('ceph:module')) + def _render_option(self, name) -> str: - cur_module = self.env.ref_context.get('ceph:module') + cur_module = self._current_module() if cur_module: opt = self._load_module(cur_module).get(name) else: @@ -369,8 +373,7 @@ class CephOption(ObjectDescription): signode += addnodes.desc_name(sig, sig) # normalize whitespace like XRefRole does name = ws_re.sub(' ', sig) - cur_module = self.options.get('module', - self.env.ref_context.get('ceph:module')) + cur_module = self._current_module() if cur_module: return '/'.join(['mgr', cur_module, name]) else: