Skip to content

Commit 592249a

Browse files
committed
Bump to 0.1.3
1 parent e5f9ddb commit 592249a

File tree

4 files changed

+54
-11
lines changed

4 files changed

+54
-11
lines changed

examples/document.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Document
2+
A model for documents
3+
#### Allowed parameters
4+
<table><tr><td><b>title</b></td><td>str</td><td><i>Document title</i></td></tr>
5+
6+
<tr><td><b>ISBN</b></td><td>int</td><td><i>International Standard Book Number</i></td></tr>
7+
8+
<tr><td><b>id</b></td><td>str</td><td><i>Unique ID of element</i></td></tr>
9+
10+
<tr><td><b>notes</b></td><td>str</td><td><i>Human readable notes</i></td></tr>
11+
12+
13+
</table>
14+
15+
#### Allowed children
16+
<table><tr><td><b>sections</b></td><td><a href="#section">Section</a></td><td><i>The sections of the document</i></td></tr>
17+
18+
19+
</table>
20+
21+
## Section
22+
A model of a section of the document
23+
#### Allowed parameters
24+
<table><tr><td><b>id</b></td><td>str</td><td><i>Unique ID of element</i></td></tr>
25+
26+
<tr><td><b>notes</b></td><td>str</td><td><i>Human readable notes</i></td></tr>
27+
28+
29+
</table>
30+
31+
#### Allowed children
32+
<table><tr><td><b>paragraphs</b></td><td><a href="#paragraph">Paragraph</a></td><td><i>The paragraphs</i></td></tr>
33+
34+
35+
</table>
36+
37+
## Paragraph
38+
A model of a paragraph
39+
#### Allowed parameters
40+
<table><tr><td><b>contents</b></td><td>str</td><td><i>Paragraph contents</i></td></tr>
41+
42+
43+
</table>
44+

examples/document.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, **kwargs):
1717

1818
super(Document, self).__init__(**kwargs)
1919

20-
print('Created:: %s'%(self))
20+
print("Created:: %s" % (self))
2121

2222

2323
class Section(BaseWithId):
@@ -46,7 +46,7 @@ def __init__(self, **kwargs):
4646
doc.title = "My life in Python"
4747

4848
a = Section(id="Abstract")
49-
p = Paragraph(contents='Blah blah blah')
49+
p = Paragraph(contents="Blah blah blah")
5050
a.paragraphs.append(p)
5151
doc.sections.append(a)
5252
doc.sections.append(Section(id="Chapter 1"))
@@ -55,3 +55,8 @@ def __init__(self, **kwargs):
5555

5656
doc.to_json_file("document.json")
5757
doc.to_yaml_file("document.yaml")
58+
59+
doc_md = doc.generate_documentation(format="markdown")
60+
61+
with open("document.md", "w") as d:
62+
d.write(doc_md)

modelspec/BaseTypes.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def __init__(self, expr):
1414
self.expr = expr
1515

1616

17-
1817
def print_(text, print_it=False):
1918
"""
2019
Print a message preceded by modelspec, only if print_it=True
@@ -69,15 +68,13 @@ def get_id(self):
6968
def get_type(self):
7069
return self.__class__.__name__
7170

72-
7371
def add_allowed_child(self, name, description, type_):
7472

7573
if self.allowed_children is None:
7674
self.allowed_children = collections.OrderedDict([])
7775

7876
self.allowed_children[name] = (description, type_)
7977

80-
8178
def add_allowed_field(self, name, description, type_):
8279
if self.allowed_fields is None:
8380
self.allowed_fields = collections.OrderedDict([])
@@ -86,11 +83,11 @@ def add_allowed_field(self, name, description, type_):
8683

8784
def __getattr__(self, name):
8885

89-
9086
if name == "id" and not "id" in self.allowed_fields:
9187
return None
9288

93-
if verbose: print_v(" > Checking the value of attribute %s in: %s..."%(name,'?'))
89+
if verbose:
90+
print_v(" > Checking the value of attribute %s in: %s..." % (name, "?"))
9491

9592
if name in self.__dict__:
9693
return self.__dict__[name]
@@ -123,7 +120,6 @@ def __getattr__(self, name):
123120

124121
return None
125122

126-
127123
@classmethod
128124
def _is_evaluable_expression(cls, value):
129125
if not hasattr(value, "__name__"):
@@ -509,7 +505,6 @@ def __init__(self, **kwargs):
509505

510506
super(BaseWithId, self).__init__(**kwargs)
511507

512-
513508
def get_id(self):
514509
if len(self.fields) == 0:
515510
return "???"

modelspec/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
2-
__version__ = "0.1.2"
1+
__version__ = "0.1.3"

0 commit comments

Comments
 (0)