Skip to content

Commit 75d7ea6

Browse files
committed
Updates to docs generation
1 parent 8e4ebd4 commit 75d7ea6

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

examples/document.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ A model for documents
3838
</table>
3939

4040
## Section
41-
A model of a section of the document. Will contain a <a href="#paragraph">Paragraph</a> or two
41+
A model of a section of the <a href="#document">Document</a>. Will contain one <a href="#paragraph">Paragraph</a> or more
4242

4343
### Allowed parameters
4444
<table>

examples/document.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Paragraph(Base):
2121
@modelspec.define
2222
class Section(Base):
2323
"""
24-
A model of a section of the document. Will contain a _Paragraph_ or two
24+
A model of a section of the :class:`Document`. Will contain one :class:`Paragraph` or more
2525
2626
Args:
2727
id: The id of the section

examples/document.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Allowed child Data Type Description
2424
=======
2525
Section
2626
=======
27-
A model of a section of the document. Will contain a Paragraph or two
27+
A model of a section of the <a href="#document">Document</a>. Will contain one <a href="#paragraph">Paragraph</a> or more
2828

2929
**Allowed parameters**
3030

src/modelspec/base_types.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,35 @@ def _cls_generate_documentation(cls, format: str = MARKDOWN_FORMAT):
524524
rst_url_format = "`%s <%s>`_"
525525

526526
def insert_links(text, format=MARKDOWN_FORMAT):
527+
528+
code_ref = ":code:`"
529+
# print(" > Converting: %s" % text)
530+
text2 = text
531+
while code_ref in text2:
532+
ind = text2.index(code_ref)
533+
ind2 = text2.index("`", ind + len(code_ref) + 1)
534+
pre = text2[0:ind]
535+
ref = text2[ind + len(code_ref) : ind2]
536+
post = text2[ind2 + 1 :]
537+
text2 = f"{pre}<b>{ref}</b>{post}"
538+
# print(" > Converted to: %s" % text2)
539+
text = text2
540+
541+
class_ref = ":class:`"
542+
# print(" > Converting: %s" % text)
543+
text2 = text
544+
while class_ref in text2:
545+
ind = text2.index(class_ref)
546+
ind2 = text2.index("`", ind + len(class_ref) + 1)
547+
pre = text2[0:ind]
548+
ref = text2[ind + len(class_ref) : ind2]
549+
if ref[0] == "~":
550+
ref = ref[1:]
551+
post = text2[ind2 + 1 :]
552+
text2 = f'{pre}<a href="#{ref.lower()}">{ref}</a>{post}'
553+
# print(" > Converted to: %s" % text2)
554+
text = text2
555+
527556
if "_" not in text:
528557
return text
529558
if '"' in text:

0 commit comments

Comments
 (0)