From 212d63a0ddc257ce60f1953846e50088f8970b6b Mon Sep 17 00:00:00 2001 From: Jesse van den Kieboom Date: Thu, 10 Jul 2014 12:18:46 +0200 Subject: [PATCH] Correctly use semantic parent in qid Fixes #53 --- cldoc/nodes/function.py | 17 ++++++----------- cldoc/nodes/node.py | 2 +- tests/input/operator.hh | 9 +++++++++ tests/output/namespace-A.xml | 4 ++-- tests/output/operator-N.xml | 4 ++++ tests/output/operator-N::A.xml | 22 ++++++++++++++++++++++ tests/output/operator-index.xml | 6 ++++++ 7 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 tests/input/operator.hh create mode 100644 tests/output/operator-N.xml create mode 100644 tests/output/operator-N::A.xml create mode 100644 tests/output/operator-index.xml diff --git a/cldoc/nodes/function.py b/cldoc/nodes/function.py index 00cf17d..553b892 100644 --- a/cldoc/nodes/function.py +++ b/cldoc/nodes/function.py @@ -97,21 +97,16 @@ def __init__(self, cursor, comment): self._arguments.append(Argument(self, child)) - @property - def qid(self): - if not isinstance(self.semantic_parent, Namespace): - return self.name - else: - return Node.qid.fget(self) - @property def semantic_parent(self): from namespace import Namespace - if isinstance(self.parent, Namespace): - return self.parent - else: - return None + parent = self.parent + + while not parent is None and not isinstance(parent, Namespace): + parent = parent.parent + + return parent @property def resolve_nodes(self): diff --git a/cldoc/nodes/node.py b/cldoc/nodes/node.py index af6263f..5a4b538 100644 --- a/cldoc/nodes/node.py +++ b/cldoc/nodes/node.py @@ -236,7 +236,7 @@ def qid(self): if not parent: return meid else: - q = self.parent.qid + q = parent.qid if not q: return meid diff --git a/tests/input/operator.hh b/tests/input/operator.hh new file mode 100644 index 0000000..fd0258e --- /dev/null +++ b/tests/input/operator.hh @@ -0,0 +1,9 @@ +namespace N +{ + struct A + { + bool operator<(const A &other); + }; + + bool operator==(const A &a, const A &b); +} diff --git a/tests/output/namespace-A.xml b/tests/output/namespace-A.xml index 8744d6b..988ac43 100644 --- a/tests/output/namespace-A.xml +++ b/tests/output/namespace-A.xml @@ -10,10 +10,10 @@ Enum E. Enum E in namespace A. - + E_1 value. - + E_2 value. diff --git a/tests/output/operator-N.xml b/tests/output/operator-N.xml new file mode 100644 index 0000000..6cc24c8 --- /dev/null +++ b/tests/output/operator-N.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/output/operator-N::A.xml b/tests/output/operator-N::A.xml new file mode 100644 index 0000000..6a47e41 --- /dev/null +++ b/tests/output/operator-N::A.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/output/operator-index.xml b/tests/output/operator-index.xml new file mode 100644 index 0000000..bbd9c8b --- /dev/null +++ b/tests/output/operator-index.xml @@ -0,0 +1,6 @@ + + + + + +