merge with 1.0

This commit is contained in:
Georg Brandl 2011-01-06 20:59:33 +01:00
commit 763789463d
5 changed files with 65 additions and 12 deletions

View File

@ -71,6 +71,8 @@ Release 1.1 (in development)
Release 1.0.7 (in development)
==============================
* #571: Implement ``~`` cross-reference prefix for the C domain.
* Fix regression of LaTeX output with the fix of #556.
* #568: Fix lookup of class attribute documentation on descriptors

View File

@ -308,6 +308,8 @@ single word, like this::
:param integer limit: maximum number of stack frames to show
.. _python-roles:
Cross-referencing Python objects
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -438,6 +440,8 @@ The C domain (name **c**) is suited for documentation of C API.
.. c:var:: PyObject* PyClass_Type
.. _c-roles:
Cross-referencing C constructs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -522,6 +526,9 @@ The following directives are available:
Select the current C++ namespace for the following objects.
.. _cpp-roles:
These roles link to the given object types:
.. rst:role:: cpp:class
@ -689,6 +696,8 @@ The JavaScript domain (name **js**) provides the following directives:
Describes the attribute *name* of *object*.
.. _js-roles:
These roles are provided to refer to the described objects:
.. rst:role:: js:func
@ -740,6 +749,8 @@ The reStructuredText domain (name **rst**) provides the following directives:
Foo description.
.. _rst-roles:
These roles are provided to refer to the described objects:
.. rst:role:: rst:dir

View File

@ -44,6 +44,18 @@ more versatile:
tool-tip on mouse-hover) will always be the full target name.
Cross-referencing objects
-------------------------
These roles are described with their respective domains:
* :ref:`Python <python-roles>`
* :ref:`C <c-roles>`
* :ref:`C++ <cpp-roles>`
* :ref:`JavaScript <js-roles>`
* :ref:`ReST <rst-roles>`
.. _ref-role:
Cross-referencing arbitrary locations

View File

@ -99,13 +99,20 @@ class CObject(ObjectDescription):
m = c_funcptr_name_re.match(name)
if m:
name = m.group(1)
typename = self.env.temp_data.get('c:type')
if self.name == 'c:member' and typename:
fullname = typename + '.' + name
else:
fullname = name
if not arglist:
if self.objtype == 'function':
# for functions, add an empty parameter list
signode += addnodes.desc_parameterlist()
if const:
signode += addnodes.desc_addname(const, const)
return name
return fullname
paramlist = addnodes.desc_parameterlist()
arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup
@ -127,7 +134,7 @@ class CObject(ObjectDescription):
signode += paramlist
if const:
signode += addnodes.desc_addname(const, const)
return name
return fullname
def get_index_text(self, name):
if self.objtype == 'function':
@ -163,6 +170,31 @@ class CObject(ObjectDescription):
if indextext:
self.indexnode['entries'].append(('single', indextext, name, name))
def before_content(self):
self.typename_set = False
if self.name == 'c:type':
if self.names:
self.env.temp_data['c:type'] = self.names[0]
self.typename_set = True
def after_content(self):
if self.typename_set:
self.env.temp_data['c:type'] = None
class CXRefRole(XRefRole):
def process_link(self, env, refnode, has_explicit_title, title, target):
if not has_explicit_title:
target = target.lstrip('~') # only has a meaning for the title
# if the first character is a tilde, don't display the module/class
# parts of the contents
if title[0:1] == '~':
title = title[1:]
dot = title.rfind('.')
if dot != -1:
title = title[dot+1:]
return title, target
class CDomain(Domain):
"""C language domain."""
@ -184,11 +216,11 @@ class CDomain(Domain):
'var': CObject,
}
roles = {
'func' : XRefRole(fix_parens=True),
'member': XRefRole(),
'macro': XRefRole(),
'data': XRefRole(),
'type': XRefRole(),
'func' : CXRefRole(fix_parens=True),
'member': CXRefRole(),
'macro': CXRefRole(),
'data': CXRefRole(),
'type': CXRefRole(),
}
initial_data = {
'objects': {}, # fullname -> docname, objtype

View File

@ -138,15 +138,11 @@
% Play with vspace to be able to keep the indentation.
\newlength\distancetoright
\newlength\leftsidespace
\def\mycolorbox#1{%
\setlength\leftsidespace{\@totalleftmargin}%
\setlength\distancetoright{\linewidth}%
\advance\distancetoright -\@totalleftmargin %
\noindent\hspace*{\@totalleftmargin}%
\fcolorbox{VerbatimBorderColor}{VerbatimColor}{%
\begin{minipage}{\distancetoright}%
\noindent\hspace*{-\leftsidespace}%
#1
\end{minipage}%
}%
@ -480,4 +476,4 @@
\raggedright
}
{\endlist}
}{}
}{}