]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
doc/_ext: define a helper for current_module()
authorKefu Chai <kchai@redhat.com>
Mon, 10 May 2021 03:56:54 +0000 (11:56 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 11 May 2021 08:05:04 +0000 (16:05 +0800)
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 <kchai@redhat.com>
doc/_ext/ceph_confval.py

index 44ef0bbf3faa6477d413bd8abd45fa791e8262e4..ffe036a6b93f1fd96f38a7a0f3894c2576befee5 100644 (file)
@@ -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: