Skip to content

Commit 6614cb3

Browse files
committed
Merge branch 'parikshit14-bug/docstring' into development
2 parents 0cdcac0 + 0706a91 commit 6614cb3

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

examples/document.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Document
2-
A model for documents
2+
A model for documents.
33

44
### Allowed parameters
55
<table>
@@ -38,7 +38,7 @@ A model for documents
3838
</table>
3939

4040
## Section
41-
Will contain one <a href="#paragraph">Paragraph</a> or more.
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>
@@ -63,7 +63,7 @@ Will contain one <a href="#paragraph">Paragraph</a> or more.
6363
</table>
6464

6565
## Paragraph
66-
A model of a paragraph
66+
A model of a paragraph.
6767

6868
### Allowed parameters
6969
<table>

examples/document.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@modelspec.define
1010
class Paragraph(Base):
1111
"""
12-
A model of a paragraph
12+
A model of a paragraph.
1313
1414
Args:
1515
contents: Paragraph contents, which make up the _Section_s.
@@ -36,7 +36,7 @@ class Section(Base):
3636
@modelspec.define
3737
class Document(Base):
3838
"""
39-
A model for documents
39+
A model for documents.
4040
4141
Args:
4242
id: The unique id of the document

examples/document.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
========
22
Document
33
========
4-
A model for documents
4+
A model for documents.
55

66
**Allowed parameters**
77

@@ -24,7 +24,7 @@ Allowed child Data Type Description
2424
=======
2525
Section
2626
=======
27-
Will contain one <a href="#paragraph">Paragraph</a> or more.
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

@@ -45,7 +45,7 @@ Allowed child Data Type Description
4545
=========
4646
Paragraph
4747
=========
48-
A model of a paragraph
48+
A model of a paragraph.
4949

5050
**Allowed parameters**
5151

examples/document.specification.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Document": {
3-
"definition": "A model for documents",
3+
"definition": "A model for documents.",
44
"allowed_parameters": {
55
"id": {
66
"type": "str",
@@ -23,7 +23,7 @@
2323
}
2424
},
2525
"Section": {
26-
"definition": "Will contain one :class:`Paragraph` or more.",
26+
"definition": "A model of a section of the :class:`Document`. Will contain one :class:`Paragraph` or more.",
2727
"allowed_parameters": {
2828
"id": {
2929
"type": "str",
@@ -38,7 +38,7 @@
3838
}
3939
},
4040
"Paragraph": {
41-
"definition": "A model of a paragraph",
41+
"definition": "A model of a paragraph.",
4242
"allowed_parameters": {
4343
"contents": {
4444
"type": "str",

examples/document.specification.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Document:
2-
definition: A model for documents
2+
definition: A model for documents.
33
allowed_parameters:
44
id:
55
type: str
@@ -15,7 +15,8 @@ Document:
1515
type: Section
1616
description: The sections of the document
1717
Section:
18-
definition: Will contain one :class:`Paragraph` or more.
18+
definition: A model of a section of the :class:`Document`. Will contain one :class:`Paragraph`
19+
or more.
1920
allowed_parameters:
2021
id:
2122
type: str
@@ -25,7 +26,7 @@ Section:
2526
type: Paragraph
2627
description: The paragraphs
2728
Paragraph:
28-
definition: A model of a paragraph
29+
definition: A model of a paragraph.
2930
allowed_parameters:
3031
contents:
3132
type: str

src/modelspec/base_types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,11 @@ def _parse_definition(cls) -> str:
373373
p = parse(cls.__doc__)
374374

375375
# Extract the description, use the long description if available.
376-
return p.long_description if p.long_description else p.short_description
376+
if p.long_description:
377+
definition = f"{p.short_description} {p.long_description}"
378+
else:
379+
definition = p.short_description
380+
return definition
377381

378382
@classmethod
379383
def _parse_allowed_fields(cls) -> Dict[str, Tuple[str, Any]]:

0 commit comments

Comments
 (0)