Skip to content

Commit 8e4ebd4

Browse files
committed
Update formatting of generated docs
1 parent 8824750 commit 8e4ebd4

File tree

2 files changed

+65
-26
lines changed

2 files changed

+65
-26
lines changed

examples/document.md

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,77 @@
11
## Document
22
A model for documents
33

4-
#### Allowed parameters
5-
<table><tr><td><b>id</b></td><td>str</td><td><i>The unique id of the document</i></td></tr>
4+
### Allowed parameters
5+
<table>
6+
<tr>
7+
<td><b>id</b></td>
8+
<td>str</td>
9+
<td><i>The unique id of the document</i></td>
10+
</tr>
611

7-
<tr><td><b>title</b></td><td>str</td><td><i>Document title</i></td></tr>
812

9-
<tr><td><b>ISBN</b></td><td>int</td><td><i>International Standard Book Number</i></td></tr>
13+
<tr>
14+
<td><b>title</b></td>
15+
<td>str</td>
16+
<td><i>Document title</i></td>
17+
</tr>
18+
19+
20+
<tr>
21+
<td><b>ISBN</b></td>
22+
<td>int</td>
23+
<td><i>International Standard Book Number</i></td>
24+
</tr>
1025

1126

1227
</table>
1328

14-
#### Allowed children
15-
<table><tr><td><b>sections</b></td><td><a href="#section">Section</a></td><td><i>The sections of the document</i></td></tr>
29+
### Allowed children
30+
<table>
31+
<tr>
32+
<td><b>sections</b></td>
33+
<td><a href="#section">Section</a></td>
34+
<td><i>The sections of the document</i></td>
35+
</tr>
1636

1737

1838
</table>
1939

2040
## Section
2141
A model of a section of the document. Will contain a <a href="#paragraph">Paragraph</a> or two
2242

23-
#### Allowed parameters
24-
<table><tr><td><b>id</b></td><td>str</td><td><i>The id of the section</i></td></tr>
43+
### Allowed parameters
44+
<table>
45+
<tr>
46+
<td><b>id</b></td>
47+
<td>str</td>
48+
<td><i>The id of the section</i></td>
49+
</tr>
2550

2651

2752
</table>
2853

29-
#### Allowed children
30-
<table><tr><td><b>paragraphs</b></td><td><a href="#paragraph">Paragraph</a></td><td><i>The paragraphs</i></td></tr>
54+
### Allowed children
55+
<table>
56+
<tr>
57+
<td><b>paragraphs</b></td>
58+
<td><a href="#paragraph">Paragraph</a></td>
59+
<td><i>The paragraphs</i></td>
60+
</tr>
3161

3262

3363
</table>
3464

3565
## Paragraph
3666
A model of a paragraph
3767

38-
#### Allowed parameters
39-
<table><tr><td><b>contents</b></td><td>str</td><td><i>Paragraph contents, which make up the <a href="#section">Section</a>s.</i></td></tr>
68+
### Allowed parameters
69+
<table>
70+
<tr>
71+
<td><b>contents</b></td>
72+
<td>str</td>
73+
<td><i>Paragraph contents, which make up the <a href="#section">Section</a>s.</i></td>
74+
</tr>
4075

4176

4277
</table>

src/modelspec/base_types.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def insert_links(text, format=MARKDOWN_FORMAT):
563563

564564
if len(allowed_fields) > 0:
565565
if format == MARKDOWN_FORMAT:
566-
doc_string += "#### Allowed parameters\n<table>"
566+
doc_string += "### Allowed parameters\n<table>"
567567
if format == RST_FORMAT:
568568
ap = "**Allowed parameters**"
569569
doc_string += "%s\n\n" % (ap)
@@ -586,13 +586,15 @@ def insert_links(text, format=MARKDOWN_FORMAT):
586586
doc_dict[name]["allowed_parameters"][f]["description"] = description
587587

588588
elif format == MARKDOWN_FORMAT:
589-
doc_string += "<tr><td><b>{}</b></td><td>{}</td>".format(
590-
f,
591-
f'<a href="#{type_str.lower()}">{type_str}</a>'
592-
if referencable
593-
else type_str,
589+
doc_string += (
590+
"\n <tr>\n <td><b>{}</b></td>\n <td>{}</td>".format(
591+
f,
592+
f'<a href="#{type_str.lower()}">{type_str}</a>'
593+
if referencable
594+
else type_str,
595+
)
594596
)
595-
doc_string += "<td><i>%s</i></td></tr>\n\n" % (
597+
doc_string += "\n <td><i>%s</i></td>\n </tr>\n\n" % (
596598
insert_links(description)
597599
)
598600

@@ -623,7 +625,7 @@ def insert_links(text, format=MARKDOWN_FORMAT):
623625

624626
if len(allowed_children) > 0:
625627
if format == MARKDOWN_FORMAT:
626-
doc_string += "#### Allowed children\n<table>"
628+
doc_string += "### Allowed children\n<table>"
627629
elif format == RST_FORMAT:
628630
ap = "**Allowed children**"
629631
doc_string += "%s\n\n" % (ap)
@@ -645,13 +647,15 @@ def insert_links(text, format=MARKDOWN_FORMAT):
645647
][0]
646648

647649
elif format == MARKDOWN_FORMAT:
648-
doc_string += "<tr><td><b>{}</b></td><td>{}</td>".format(
649-
c,
650-
f'<a href="#{type_str.lower()}">{type_str}</a>'
651-
if referencable
652-
else type_str,
650+
doc_string += (
651+
"\n <tr>\n <td><b>{}</b></td>\n <td>{}</td>".format(
652+
c,
653+
f'<a href="#{type_str.lower()}">{type_str}</a>'
654+
if referencable
655+
else type_str,
656+
)
653657
)
654-
doc_string += "<td><i>%s</i></td></tr>\n\n" % (
658+
doc_string += "\n <td><i>%s</i></td>\n </tr>\n\n" % (
655659
insert_links(description)
656660
)
657661

0 commit comments

Comments
 (0)