mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch 'cxx2a-concepts' of git://github.com/mickk-on-cpp/sphinx into mickk-on-cpp-cxx2a-concepts
This commit is contained in:
commit
697248aec7
1
CHANGES
1
CHANGES
@ -75,6 +75,7 @@ Features removed
|
||||
* ``sphinx.util.nodes.process_only_nodes()``
|
||||
* LaTeX environment ``notice``, use ``sphinxadmonition`` instead
|
||||
* LaTeX ``\sphinxstylethead``, use ``\sphinxstyletheadfamily``
|
||||
* C++, support of function concepts
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
@ -720,13 +720,12 @@ a visibility statement (``public``, ``private`` or ``protected``).
|
||||
|
||||
|
||||
.. rst:directive:: .. cpp:concept:: template-parameter-list name
|
||||
.. cpp:concept:: template-parameter-list name()
|
||||
|
||||
.. warning:: The support for concepts is experimental. It is based on the
|
||||
Concepts Technical Specification, and the features may change as the TS evolves.
|
||||
|
||||
Describe a variable concept or a function concept. Both must have exactly 1
|
||||
template parameter list. The name may be a nested name. Examples::
|
||||
Describe a concept. It must have exactly 1 template parameter list. The name may be a
|
||||
nested name. Example::
|
||||
|
||||
.. cpp:concept:: template<typename It> std::Iterator
|
||||
|
||||
@ -744,12 +743,7 @@ a visibility statement (``public``, ``private`` or ``protected``).
|
||||
- :cpp:expr:`*r`, when :cpp:expr:`r` is dereferenceable.
|
||||
- :cpp:expr:`++r`, with return type :cpp:expr:`It&`, when :cpp:expr:`r` is incrementable.
|
||||
|
||||
.. cpp:concept:: template<typename Cont> std::Container()
|
||||
|
||||
Holder of elements, to which it can provide access via
|
||||
:cpp:concept:`Iterator` s.
|
||||
|
||||
They will render as follows:
|
||||
This will render as follows:
|
||||
|
||||
.. cpp:concept:: template<typename It> std::Iterator
|
||||
|
||||
@ -767,11 +761,6 @@ a visibility statement (``public``, ``private`` or ``protected``).
|
||||
- :cpp:expr:`*r`, when :cpp:expr:`r` is dereferenceable.
|
||||
- :cpp:expr:`++r`, with return type :cpp:expr:`It&`, when :cpp:expr:`r` is incrementable.
|
||||
|
||||
.. cpp:concept:: template<typename Cont> std::Container()
|
||||
|
||||
Holder of elements, to which it can provide access via
|
||||
:cpp:concept:`Iterator` s.
|
||||
|
||||
Options
|
||||
.......
|
||||
|
||||
|
@ -224,13 +224,12 @@ logger = logging.getLogger(__name__)
|
||||
concept_object:
|
||||
goal:
|
||||
just a declaration of the name (for now)
|
||||
either a variable concept or function concept
|
||||
|
||||
grammar: only a single template parameter list, and the nested name
|
||||
may not have any template argument lists
|
||||
|
||||
"template" "<" template-parameter-list ">"
|
||||
nested-name-specifier "()"[opt]
|
||||
nested-name-specifier
|
||||
|
||||
type_object:
|
||||
goal:
|
||||
@ -2780,10 +2779,9 @@ class ASTTypeUsing(ASTBase):
|
||||
|
||||
|
||||
class ASTConcept(ASTBase):
|
||||
def __init__(self, nestedName, isFunction, initializer):
|
||||
# type: (Any, bool, Any) -> None
|
||||
def __init__(self, nestedName, initializer):
|
||||
# type: (Any, Any) -> None
|
||||
self.nestedName = nestedName
|
||||
self.isFunction = isFunction # otherwise it's a variable concept
|
||||
self.initializer = initializer
|
||||
|
||||
@property
|
||||
@ -2800,18 +2798,13 @@ class ASTConcept(ASTBase):
|
||||
def __unicode__(self):
|
||||
# type: () -> unicode
|
||||
res = text_type(self.nestedName)
|
||||
if self.isFunction:
|
||||
res += "()"
|
||||
if self.initializer:
|
||||
res += text_type(self.initializer)
|
||||
return res
|
||||
|
||||
def describe_signature(self, signode, mode, env, symbol):
|
||||
# type: (addnodes.desc_signature, unicode, BuildEnvironment, Symbol) -> None
|
||||
signode += nodes.Text(text_type("bool "))
|
||||
self.nestedName.describe_signature(signode, mode, env, symbol)
|
||||
if self.isFunction:
|
||||
signode += nodes.Text("()")
|
||||
if self.initializer:
|
||||
self.initializer.describe_signature(signode, mode, env, symbol)
|
||||
|
||||
@ -4718,20 +4711,9 @@ class DefinitionParser(object):
|
||||
def _parse_concept(self):
|
||||
# type: () -> ASTConcept
|
||||
nestedName = self._parse_nested_name()
|
||||
isFunction = False
|
||||
|
||||
self.skip_ws()
|
||||
if self.skip_string('('):
|
||||
isFunction = True
|
||||
self.skip_ws()
|
||||
if not self.skip_string(')'):
|
||||
self.fail("Expected ')' in function concept declaration.")
|
||||
|
||||
initializer = self._parse_initializer('member')
|
||||
if initializer and isFunction:
|
||||
self.fail("Function concept with initializer.")
|
||||
|
||||
return ASTConcept(nestedName, isFunction, initializer)
|
||||
return ASTConcept(nestedName, initializer)
|
||||
|
||||
def _parse_class(self):
|
||||
# type: () -> ASTClass
|
||||
|
@ -231,10 +231,6 @@ def test_concept_definitions():
|
||||
{2:'I0EN1A1B7ConceptE'})
|
||||
check('concept', 'template<typename A, typename B, typename ...C> Foo',
|
||||
{2:'I00DpE3Foo'})
|
||||
check('concept', 'template<typename Param> A::B::Concept()',
|
||||
{2:'I0EN1A1B7ConceptE'})
|
||||
check('concept', 'template<typename A, typename B, typename ...C> Foo()',
|
||||
{2:'I00DpE3Foo'})
|
||||
with pytest.raises(DefinitionError):
|
||||
parse('concept', 'Foo')
|
||||
with pytest.raises(DefinitionError):
|
||||
|
Loading…
Reference in New Issue
Block a user