Skip to content

Commit

Permalink
Merge pull request #90 from jabraham17/fix-links
Browse files Browse the repository at this point in the history
Fix links for nested types

Reviewed by @lydia-duncan
  • Loading branch information
jabraham17 authored Mar 11, 2024
2 parents ae6f217 + f5b4ae4 commit e00a752
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
1 change: 1 addition & 0 deletions doc-test/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Module 'Foo'
Containers
foo
cpp_test
nested

**Does it work???**

Expand Down
22 changes: 22 additions & 0 deletions doc-test/nested.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. default-domain:: chpl

Module: MyMod
==============

.. module:: MyMod

.. record:: TopLevel

.. method:: proc foo

.. record:: Inner

.. method:: proc bar

.. method:: proc baz

.. record:: TopLevel2

.. record:: Inner

.. method:: proc bar
27 changes: 14 additions & 13 deletions sphinxcontrib/chapeldomain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,6 @@ def add_target_and_index(self, name_cls, sig, signode):
self.indexnode['entries'].append(('single', indextext,
fullname, '', None))

def before_content(self):
"""Called before parsing content. Set flag to help with class scoping.
"""
self.clsname_set = False

def after_content(self):
"""Called after parsing content. If any classes were added to the env
temp_data, make sure they are removed.
"""
if self.clsname_set:
self.env.temp_data.pop('chpl:class', None)


class ChapelModule(Directive):
"""Directive to make description of a new module."""
Expand Down Expand Up @@ -596,7 +584,20 @@ def before_content(self):
ChapelObject.before_content(self)
if self.names:
self.env.temp_data['chpl:class'] = self.names[0][0]
self.clsname_set = True
if not hasattr(self, 'clsname_set'):
self.clsname_set = 0
self.clsname_set += 1

def after_content(self):
"""Called after parsing content. Pop the class name from the longer
class name
"""
if self.clsname_set > 0:
val = self.env.temp_data.pop('chpl:class', None)
if val:
elms = val.split('.')[:-1]
self.env.temp_data['chpl:class'] = '.'.join(elms)
self.clsname_set -= 1


class ChapelModuleLevel(ChapelObject):
Expand Down

0 comments on commit e00a752

Please sign in to comment.