Skip to content

Commit e00a752

Browse files
authored
Merge pull request #90 from jabraham17/fix-links
Fix links for nested types Reviewed by @lydia-duncan
2 parents ae6f217 + f5b4ae4 commit e00a752

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

Diff for: doc-test/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Module 'Foo'
2121
Containers
2222
foo
2323
cpp_test
24+
nested
2425

2526
**Does it work???**
2627

Diff for: doc-test/nested.rst

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. default-domain:: chpl
2+
3+
Module: MyMod
4+
==============
5+
6+
.. module:: MyMod
7+
8+
.. record:: TopLevel
9+
10+
.. method:: proc foo
11+
12+
.. record:: Inner
13+
14+
.. method:: proc bar
15+
16+
.. method:: proc baz
17+
18+
.. record:: TopLevel2
19+
20+
.. record:: Inner
21+
22+
.. method:: proc bar

Diff for: sphinxcontrib/chapeldomain/__init__.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -422,18 +422,6 @@ def add_target_and_index(self, name_cls, sig, signode):
422422
self.indexnode['entries'].append(('single', indextext,
423423
fullname, '', None))
424424

425-
def before_content(self):
426-
"""Called before parsing content. Set flag to help with class scoping.
427-
"""
428-
self.clsname_set = False
429-
430-
def after_content(self):
431-
"""Called after parsing content. If any classes were added to the env
432-
temp_data, make sure they are removed.
433-
"""
434-
if self.clsname_set:
435-
self.env.temp_data.pop('chpl:class', None)
436-
437425

438426
class ChapelModule(Directive):
439427
"""Directive to make description of a new module."""
@@ -596,7 +584,20 @@ def before_content(self):
596584
ChapelObject.before_content(self)
597585
if self.names:
598586
self.env.temp_data['chpl:class'] = self.names[0][0]
599-
self.clsname_set = True
587+
if not hasattr(self, 'clsname_set'):
588+
self.clsname_set = 0
589+
self.clsname_set += 1
590+
591+
def after_content(self):
592+
"""Called after parsing content. Pop the class name from the longer
593+
class name
594+
"""
595+
if self.clsname_set > 0:
596+
val = self.env.temp_data.pop('chpl:class', None)
597+
if val:
598+
elms = val.split('.')[:-1]
599+
self.env.temp_data['chpl:class'] = '.'.join(elms)
600+
self.clsname_set -= 1
600601

601602

602603
class ChapelModuleLevel(ChapelObject):

0 commit comments

Comments
 (0)