app: allow giving the localized object name when adding new object types.

This commit is contained in:
Georg Brandl
2009-09-08 00:04:05 +02:00
parent a47e1c4e17
commit b4ef4bd670
2 changed files with 8 additions and 5 deletions

View File

@@ -132,5 +132,6 @@ def setup(app):
parse_directive)
app.add_description_unit('role', 'role', 'pair: %s; role', parse_role)
app.add_description_unit('confval', 'confval',
'pair: %s; configuration value')
objname='configuration value',
indextemplate='pair: %s; configuration value')
app.add_description_unit('event', 'event', 'pair: %s; event', parse_event)

View File

@@ -379,9 +379,10 @@ class Sphinx(object):
all_domains[domain].roles[name] = role
def add_object_type(self, directivename, rolename, indextemplate='',
parse_node=None, ref_nodeclass=None):
parse_node=None, ref_nodeclass=None, objname=''):
# XXX document objname
StandardDomain.object_types[directivename] = \
ObjType(directivename, rolename)
ObjType(objname or directivename, rolename)
# create a subclass of GenericObject as the new directive
new_directive = type(directivename, (GenericObject, object),
{'indextemplate': indextemplate,
@@ -394,9 +395,10 @@ class Sphinx(object):
add_description_unit = add_object_type
def add_crossref_type(self, directivename, rolename, indextemplate='',
ref_nodeclass=None):
ref_nodeclass=None, objname=''):
# XXX document objname
StandardDomain.object_types[directivename] = \
ObjType(directivename, rolename)
ObjType(objname or directivename, rolename)
# create a subclass of Target as the new directive
new_directive = type(directivename, (Target, object),
{'indextemplate': indextemplate})