Skip to content

Commit 7e3368c

Browse files
committed
Migrate some docstrings to ReST
1 parent 72ed022 commit 7e3368c

21 files changed

+143
-149
lines changed

appyter/ext/pathlib/assertions.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

appyter/fields.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
''' ```eval_rst
1+
'''
22
This module contains :class:`appyter.fields.Field`, the base class for all fields
33
defined in :mod:`appyter.profiles.default.fields`.
4-
``` '''
4+
'''
55

66
from markupsafe import Markup
77
from appyter.ext.flask import request_get
88

99
class PartialField:
1010
''' Partial instantiation of a field
1111
Replaces a decorator so that we can still identify it as
12-
a callable which will produce a field.
12+
a callable which will produce a field.
1313
'''
1414
def __init__(self, field, **kwargs):
1515
self._field = field
@@ -47,10 +47,9 @@ def as_dict(self):
4747

4848
class Field(dict):
4949
''' Base field for which all fields derive
50-
```eval_rst
5150
Base class for all Field objects representing a value that will later be provided via a front-end form.
5251
See :mod:`appyter.profiles.default.fields` for the actual fields.
53-
``` '''
52+
'''
5453
def __init__(self,
5554
name=None,
5655
label=None,
@@ -62,7 +61,7 @@ def __init__(self,
6261
section=None,
6362
_env=None,
6463
**kwargs):
65-
'''
64+
r'''
6665
:param name: (str) A name that will be used to refer to the object as a variable and in the HTML form.
6766
:param label: (str) A human readable label for the field for the HTML form
6867
:param description: (Optional[str]) A long human readable description for the field for the HTML form
@@ -71,7 +70,7 @@ def __init__(self,
7170
:param default: (Any) A default value as an example and for use during prototyping
7271
:param section: (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
7372
:param value: (INTERNAL Any) The raw value of the field (from the form for instance)
74-
:param **kwargs: Additional keyword arguments used by other fields
73+
:param \**kwargs: Additional keyword arguments used by other fields
7574
'''
7675
super().__init__(
7776
field=self.field,
@@ -113,7 +112,7 @@ def constraint(self):
113112
return (self.raw_value is None and not self.args.get('required')) or (self.raw_value in self.choices)
114113

115114
def render(self, **kwargs):
116-
''' Return a rendered version of the field (form)
115+
r''' Return a rendered version of the field (form)
117116
118117
:param \**kwargs: The instance values of the form e.g. `Field.render(**field.args)`
119118
'''

appyter/magic.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
''' IPython magic for making templating easy~. This basically
1+
r'''
2+
IPython magic for making templating easy~. This basically
23
just allows our jinja-type language to be executed in place
34
injecting the defaults into the environment so we can easily
45
debug the notebook at the same time as building the appyter.
@@ -10,25 +11,24 @@
1011
1112
Usage (put the following in the first cell):
1213
13-
```python
14-
#%%appyter init
15-
from appyter import magic
16-
magic.init(lambda _=globals: _())
17-
```
14+
.. code-block:: python
15+
16+
#%%appyter init
17+
from appyter import magic
18+
magic.init(lambda _=globals: _())
1819
'''
1920

2021
'''
2122
Setup given globals
2223
'''
2324
def init(_globals, verbose=False, ipynb='app.ipynb', mode='magic', safe_mode=False, **kwargs):
24-
''' Initialize appyter magic.
25+
r''' Initialize appyter magic.
2526
2627
Sets up a jinj2 environment and injects %%appyter magic into your environment.
2728
28-
:param _globals: (Dict[str, Any]) A callable with your globals for the purpose of injection, basically just: `lambda _=globals: _()`
29+
:param _globals: (Dict[str, Any]) A callable with your globals for the purpose of injection, basically just: ``lambda _=globals: _()``
2930
:param verbose: (Optional[bool]) Expand exception reporting to be more verbose
3031
'''
31-
import os
3232
import jinja2
3333
import jinja2.meta
3434
import traceback
@@ -37,23 +37,29 @@ def init(_globals, verbose=False, ipynb='app.ipynb', mode='magic', safe_mode=Fal
3737
from IPython.core.magic import register_cell_magic
3838
from IPython.display import display, Markdown, HTML
3939

40-
'''
40+
r'''
4141
register_cell_magic allows function to execute an entire cell with the following call structure:
42-
```python
43-
%%my_magic whatever
44-
all
45-
my
46-
data
47-
```
48-
Results in a call:
49-
```python
50-
my_magic(
51-
"whatever",
52-
"""all
42+
43+
.. code-block:: python
44+
45+
%%my_magic whatever
46+
all
5347
my
54-
data"""
55-
)
56-
```
48+
data
49+
50+
Results in a call:
51+
52+
.. code-block:: python
53+
54+
my_magic(
55+
"whatever",
56+
"""
57+
all
58+
my
59+
data
60+
"""
61+
)
62+
5763
'''
5864

5965
@register_cell_magic

appyter/profiles/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
''' ```eval_rst
1+
'''
22
Each submodule represents a profile extending from :mod:`appyter.profiles.default` which provide different rendering themes.
3-
``` '''
3+
'''
44

55
import os
66
from appyter.cli import cli
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
''' Bare profile with no styling.
2-
```eval_rst
32
The default profile contains the :mod:`appyter.profiles.default.fields`, :mod:`appyter.profiles.default.filters`, and :mod:`appyter.profiles.default.templates` usable by all other profiles.
4-
```
53
'''

appyter/profiles/default/fields/AutocompleteField.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from appyter.ext.re import re_full
44

55
class AutocompleteField(Field):
6-
''' Representing a field that accepts a string with autocomplete.
6+
r''' Representing a field that accepts a string with autocomplete.
77
Auto complete will use `choices` or alternatively `file_path` -- a url to load the choices as an array.
88
99
Be careful with this field, consider defining a constraint regex. Note that it is equivalent to
@@ -21,7 +21,7 @@ class AutocompleteField(Field):
2121
:param examples: (Optional[Union[List[str], Dict[str, str]]]) Named strings to provide as clickable examples
2222
:param section: (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
2323
:param value: (INTERNAL Any) The raw value of the field (from the form for instance)
24-
:param **kwargs: Additional keyword arguments used by other fields
24+
:param \**kwargs: Additional keyword arguments used by other fields
2525
'''
2626
def __init__(self, constraint=r'.*', hint=None, **kwargs):
2727
super().__init__(

appyter/profiles/default/fields/BoolField.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from appyter.fields import Field
22

33
class BoolField(Field):
4-
''' Represing a true or false value with a checkbox.
4+
r''' Represing a true or false value with a checkbox.
55
66
:param name: (str) A name that will be used to refer to the object as a variable and in the HTML form.
77
:param label: (str) A human readable label for the field for the HTML form
@@ -12,7 +12,7 @@ class BoolField(Field):
1212
:param yes_label: (Optional[str]) The text instead of "Yes"
1313
:param no_label: (Optional[str]) The text instead of "No"
1414
:param value: (INTERNAL Any) The raw value of the field (from the form for instance)
15-
:param **kwargs: Additional keyword arguments used by other fields
15+
:param \**kwargs: Additional keyword arguments used by other fields
1616
'''
1717
def __init__(self, **kwargs):
1818
super().__init__(**kwargs)

appyter/profiles/default/fields/ChoiceField.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from appyter.fields import Field
22

33
class ChoiceField(Field):
4-
''' Represing a choice of string values with a combo box.
4+
r''' Represing a choice of string values with a combo box.
55
66
:param name: (str) A name that will be used to refer to the object as a variable and in the HTML form.
77
:param label: (str) A human readable label for the field for the HTML form
@@ -11,7 +11,7 @@ class ChoiceField(Field):
1111
:param default: (str) A default value as an example and for use during prototyping
1212
:param section: (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
1313
:param value: (INTERNAL Any) The raw value of the field (from the form for instance)
14-
:param **kwargs: Additional keyword arguments used by other fields
14+
:param \**kwargs: Additional keyword arguments used by other fields
1515
'''
1616
def __init__(self, **kwargs):
1717
super().__init__(**kwargs)

appyter/profiles/default/fields/DescriptionField.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
from appyter.fields import Field
22

33
class DescriptionField(Field):
4-
''' Representing text between fields
4+
r'''
5+
Representing text between fields
56
6-
Usage:
7-
```python
8-
{% do DescriptionField(
9-
name='my_fieldname',
10-
text='My Description',
11-
) %}
12-
```
7+
.. code-block:: python
8+
9+
{% do DescriptionField(
10+
name='my_fieldname',
11+
text='My Description',
12+
) %}
1313
1414
:param name: (str) A name that will be used to refer to the object as a variable and in the HTML form.
1515
:param text: (str) A human readable, HTML parsable text
1616
:param section: (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
17-
:param **kwargs: Additional keyword arguments used by other fields
17+
:param \**kwargs: Additional keyword arguments used by other fields
1818
'''
1919
def __init__(self, **kwargs):
2020
super().__init__(**kwargs)

appyter/profiles/default/fields/FileField.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
from appyter.ext.re import re_full
77

88
class FileField(Field):
9-
''' Representing a File URL.
9+
r'''
10+
Representing a File URL.
1011
1112
The field ends up being a string of the file path, which will be relative to the appyter notebook.
12-
```python
13-
import pandas as pd
14-
df = pd.read_csv({{ FileField(name='my-csv', label='My CSV') }})
15-
```
13+
14+
.. code-block:: python
15+
16+
import pandas as pd
17+
df = pd.read_csv({{ FileField(name='my-csv', label='My CSV') }})
1618
1719
Importantly, a FileField ultimately resolves to a URL supporting several schemes. Appyters ensure
1820
that url is available as an actual file when the appyter executes.
@@ -28,7 +30,7 @@ class FileField(Field):
2830
paths can be relative i.e. `{ "my_file.txt": url_for('static', filename='my_file.txt') }`, or a remote url.
2931
:param section: (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
3032
:param value: (INTERNAL Any) The raw value of the field (from the form for instance)
31-
:param **kwargs: Remaining arguments passed down to :class:`appyter.fields.Field`'s constructor.
33+
:param \**kwargs: Remaining arguments passed down to :class:`appyter.fields.Field`'s constructor.
3234
'''
3335
def __init__(self, default=None, constraint=r'.*', **kwargs):
3436
super().__init__(

0 commit comments

Comments
 (0)