Skip to content

Commit 1d9c086

Browse files
committed
fix undone changes
1 parent f8babb2 commit 1d9c086

File tree

2 files changed

+48
-27
lines changed

2 files changed

+48
-27
lines changed

examples/document.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@ A model for documents.
55

66
**Allowed parameters**
77

8-
=============== =========== ====================================
8+
=============== =========== ==================================
99
Allowed field Data Type Description
10-
=============== =========== ====================================
11-
**id** str *The unique id of the document*
12-
**title** str *Document title*
13-
**ISBN** int *International Standard Book Number*
14-
=============== =========== ====================================
10+
=============== =========== ==================================
11+
**id** str The unique id of the document
12+
**title** str Document title
13+
**ISBN** int International Standard Book Number
14+
=============== =========== ==================================
1515

1616
**Allowed children**
1717

18-
=============== ====================== ==============================
18+
=============== ====================== ============================
1919
Allowed child Data Type Description
20-
=============== ====================== ==============================
21-
**sections** `Section <#section>`__ *The sections of the document*
22-
=============== ====================== ==============================
20+
=============== ====================== ============================
21+
**sections** `Section <#section>`__ The sections of the document
22+
=============== ====================== ============================
2323

2424
=======
2525
Section
2626
=======
27-
A model of a section of the `Document <#document>`__ . Will contain one `Paragraph <#paragraph>`__ or more.
27+
A model of a section of the `Document <#document>`__. Will contain one `Paragraph <#paragraph>`__ or more, i.e the `Paragraph(s) <#paragraph>`__ in the section, probably related to the **title** of the `Document <#document>`_.
2828

2929
**Allowed parameters**
3030

31-
=============== =========== =======================
31+
=============== =========== =====================
3232
Allowed field Data Type Description
33-
=============== =========== =======================
34-
**id** str *The id of the section*
35-
=============== =========== =======================
33+
=============== =========== =====================
34+
**id** str The id of the section
35+
=============== =========== =====================
3636

3737
**Allowed children**
3838

39-
=============== ========================== ================
39+
=============== ========================== ==============
4040
Allowed child Data Type Description
41-
=============== ========================== ================
42-
**paragraphs** `Paragraph <#paragraph>`__ *The paragraphs*
43-
=============== ========================== ================
41+
=============== ========================== ==============
42+
**paragraphs** `Paragraph <#paragraph>`__ The paragraphs
43+
=============== ========================== ==============
4444

4545
=========
4646
Paragraph
@@ -49,8 +49,8 @@ A model of a paragraph.
4949

5050
**Allowed parameters**
5151

52-
=============== =========== ===================================================
52+
=============== =========== ==============================================================
5353
Allowed field Data Type Description
54-
=============== =========== ===================================================
55-
**contents** str *Paragraph contents, which make up the _Section_s.*
56-
=============== =========== ===================================================
54+
=============== =========== ==============================================================
55+
**contents** str Paragraph contents, which make up the `Sections <#section>`__.
56+
=============== =========== ==============================================================

src/modelspec/base_types.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,12 @@ def insert_links(text, format=MARKDOWN_FORMAT):
594594
pre = text2[0:ind]
595595
ref = text2[ind + len(code_ref) : ind2]
596596
post = text2[ind2 + 1 :]
597-
text2 = f"{pre}<b>{ref}</b>{post}"
597+
598+
if format == MARKDOWN_FORMAT:
599+
text2 = f"{pre}<b>{ref}</b>{post}"
600+
elif format == RST_FORMAT:
601+
text2 = f"{pre}**{ref}**{post}"
602+
598603
# print(" > Converted to: %s" % text2)
599604
text = text2
600605

@@ -612,7 +617,23 @@ def insert_links(text, format=MARKDOWN_FORMAT):
612617
if format == MARKDOWN_FORMAT:
613618
text2 = f'{pre}<a href="#{ref.lower()}">{ref}</a>{post}'
614619
elif format == RST_FORMAT:
615-
text2 = f"{pre}`{ref} <#{ref.lower()}>`__ {post}"
620+
rr = ref
621+
pp = post
622+
623+
######################################
624+
# Some hardcoded fixes for plurals...
625+
if pp.startswith("s "):
626+
rr += "s"
627+
pp = pp[1:]
628+
if pp.startswith("s."):
629+
rr += "s"
630+
pp = pp[1:]
631+
if pp.startswith("(s)"):
632+
rr += "(s)"
633+
pp = pp[3:]
634+
######################################
635+
636+
text2 = f"{pre}`{rr} <#{ref.lower()}>`__{pp}"
616637

617638
# print(" > Converted to: %s" % text2)
618639
text = text2
@@ -694,7 +715,7 @@ def insert_links(text, format=MARKDOWN_FORMAT):
694715
if referencable
695716
else type_str,
696717
)
697-
d = "*%s*" % (insert_links(description, format=RST_FORMAT))
718+
d = "%s" % (insert_links(description, format=RST_FORMAT))
698719
table_info.append([n, t, d])
699720

700721
if referencable:
@@ -755,7 +776,7 @@ def insert_links(text, format=MARKDOWN_FORMAT):
755776
if referencable
756777
else type_str,
757778
)
758-
d = "*%s*" % (insert_links(description, format=RST_FORMAT))
779+
d = "%s" % (insert_links(description, format=RST_FORMAT))
759780
table_info.append([n, t, d])
760781

761782
# Get the contained type

0 commit comments

Comments
 (0)