mirror of
https://github.com/ceph/ceph
synced 2025-01-03 09:32:43 +00:00
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 <kchai@redhat.com>
This commit is contained in:
parent
f948b5acf7
commit
44e611ce30
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user