Skip to content

Commit 8ad070f

Browse files
committed
fix markdown formatting
1 parent 4907ba2 commit 8ad070f

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

docs/components.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
This toolkit consists of three components.
44

5-
The first component ([](/src/rpft/parsers/common)) is RapidPro-agnostic and takes care of reader spreadsheets and converting them into internal data models and other output formats, see [](sheets.md)
5+
The first component ([/src/rpft/parsers/common]) is RapidPro-agnostic and takes care of reader spreadsheets and converting them into internal data models and other output formats, see [sheets.md]
66

7-
The second component ([](/src/rpft/parsers/creation)) defines data models for a spreadsheet format for RapidPro flows, and process spreadsheets into RapidPro flows (and back) using the first component.
7+
The second component ([/src/rpft/parsers/creation]) defines data models for a spreadsheet format for RapidPro flows, and process spreadsheets into RapidPro flows (and back) using the first component.
88

9-
The third component ([](/src/rpft/rapidpro)) defines internal representations of RapidPro flows and to read and write to a JSON format that can be import to/exported from RapidPro. It is partially entangled with the second component, as it needs to be aware of the data models of the second component to convert RapidPro flows into the spreadsheet format.
9+
The third component ([/src/rpft/rapidpro]) defines internal representations of RapidPro flows and to read and write to a JSON format that can be import to/exported from RapidPro. It is partially entangled with the second component, as it needs to be aware of the data models of the second component to convert RapidPro flows into the spreadsheet format.
1010

11-
The latter two components are (poorly) documented here: [](rapidpro.md)
11+
The latter two components are (poorly) documented here: [rapidpro.md]

docs/models.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Models
22

3-
`RowModel`s are subclasses of [`pydantic.BaseModel`]
4-
(https://docs.pydantic.dev/latest/concepts/models/#basic-model-usage), and may
3+
`RowModel`s are subclasses of [`pydantic.BaseModel`](https://docs.pydantic.dev/latest/concepts/models/#basic-model-usage), and may
54
contain basic types, lists and other models as attributes, nested arbirarily
65
deep. Every `Sheet` can only be parsed in the context of a given `RowModel`
76
(which can, however, be automatically inferred from the sheet headers, if desired).
87

98
Technically, there is no `RowModel` class, but instead it is called `ParserModel`
10-
and is defined in [](/src/rpft/parsers/common/rowparser.py). `ParserModel` attributes have to be
9+
and is defined in [/src/rpft/parsers/common/rowparser.py]. `ParserModel` attributes have to be
1110
basic types, lists or `ParserModel`s.
1211
The only addition to `pydantic.BaseModel` are the (optional) methods `header_name_to_field_name`, `field_name_to_header_name` and (for full row models) `header_name_to_field_name_with_context` that allow remapping
1312
column header names to different model attributes.
@@ -20,8 +19,7 @@ class SubModel(ParserModel):
2019
number: int = 0
2120
2221
class MyModel(ParserModel):
23-
numbers: List[int] = []
24-
sub: SubModel = SubModel()
22+
numbers: List[int] = [ sub: SubModel = SubModel()
2523
```
2624

2725
The headers of a sheet and its content that can be parsed into `MyModel` could for example be:
@@ -46,9 +44,9 @@ How sheets and their column headers correspond to `RowModel`s is specified in
4644

4745
More examples can also be found in the tests:
4846

49-
- [](/src/rpft/parsers/common/tests/test_rowparser.py)
50-
- [](/src/rpft/parsers/common/tests/test_full_rows.py)
51-
- [](/src/rpft/parsers/common/tests/test_differentways.py)
47+
- [/src/rpft/parsers/common/tests/test_rowparser.py]
48+
- [/src/rpft/parsers/common/tests/test_full_rows.py]
49+
- [/src/rpft/parsers/common/tests/test_differentways.py]
5250

5351

5452
The `header_name_to_field_name` and related `ParserModel` methods can be used to map column headers to fields of a different name, for example:

docs/rapidpro.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ There are two sheet types of particular interest
1818
- [`DataSheet`](/src/rpft/parsers/creation/contentindexparser.py): Similar to a [`RowDataSheet`](sheets.md), however, assumed that the `RowModel` has an `ID` field, and rather than storing a list of rows, it stores an ordered dict of rows, indexed by their ID.
1919
- [`TemplateSheet`](/src/rpft/parsers/creation/contentindexparser.py): Wrapper around `tablib.Dataset`, with template arguments.
2020

21-
Note: It may be worthwhile unifying the data structures used here, to be consistent with `Sheet` and `RowDataSheet` documented in [](sheets.md). Also see the discussion there why `DataSheet`s can be exported to nested JSON, while `TemplateSheet`s can only be exported to flat JSON.
21+
Note: It may be worthwhile unifying the data structures used here, to be consistent with `Sheet` and `RowDataSheet` documented in [sheets.md]. Also see the discussion there why `DataSheet`s can be exported to nested JSON, while `TemplateSheet`s can only be exported to flat JSON.
2222

2323
`DataSheet`s are often used to instantiate `TemplateSheet`s, and the ContentIndexParser has mechanisms for this, see [New features documentation]. Furthermore, `DataSheet`s can also be concatenated, filtered and sorted via the `operation` column, see [here](https://docs.google.com/document/d/1Onx2RhNoWKW9BQvFrgTc5R5hcwDy1OMsLKnNB7YxQH0/edit#heading=h.c93jouk7sqq)
2424

2525

2626

27-
Relevant code: `parse_all_flows` in [](/src/rpft/parsers/creation/contentindexparser.py).
27+
Relevant code: `parse_all_flows` in [/src/rpft/parsers/creation/contentindexparser.py].
2828

2929
Examples:
3030

docs/sheets.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ details of the three conversion steps below.
4747

4848
## Conversion between spreadsheet files and `Sheet`s
4949

50-
SheetReaders and `Sheet`s are defined in [](/src/rpft/parsers/sheets.py)
50+
SheetReaders and `Sheet`s are defined in [/src/rpft/parsers/sheets.py]
5151

5252
The `Sheet` class wraps [`tablib.Dataset`]
5353
(https://tablib.readthedocs.io/en/stable/api.html#dataset-object) (which is
@@ -95,7 +95,7 @@ instances. `RowModel`s are subclasses of [`pydantic.BaseModel`]
9595
(https://docs.pydantic.dev/latest/concepts/models/#basic-model-usage), and may
9696
contain basic types, lists and other models as attributes, nested arbirarily
9797
deep. How sheets and their column headers correspond to `RowModel`s is
98-
documented in more detail in [](models.md).
98+
documented in more detail in [models.md].
9999

100100

101101
### Forward direction
@@ -127,7 +127,7 @@ row into a `RowModel` instance containing the provided data.
127127
corresponding entry of the spreadsheet in this row, and is provided
128128
by the `SheetParser`. Column headers determine which field of the
129129
model the column contains data for, and different ways to address fields
130-
in the data models are supported, see [](models.md).
130+
in the data models are supported, see [models.md].
131131

132132
The `RowParser` interprets the column headers and if the column contains
133133
a non-basic type (e.g. a list or a submodel), it invokes the `CellParser`
@@ -148,7 +148,7 @@ Examples:
148148
- `a\;b` --> 'a;b'
149149
- `a,b|1,2` --> [['a','b'],['1','2']]
150150

151-
More examples can be found in [](/tests/test_cellparser.py).
151+
More examples can be found in [/tests/test_cellparser.py].
152152

153153

154154
#### Templating
@@ -160,7 +160,7 @@ With a given templating context mapping variable names to values
160160
(e.g. {"user_name": "Chris"), such a string can be evaluated,
161161
e.g. to `Hello Chris!`.
162162

163-
More examples can be found in [](/tests/test_cellparser.py).
163+
More examples can be found in [/tests/test_cellparser.py].
164164

165165

166166
##### Instantiating templated sheets
@@ -253,7 +253,7 @@ or a reference to an already defined model).
253253

254254

255255
The CLI command `save_data_sheets` implements exporting all data sheets referenced in
256-
a content index as (a single) nested JSON. This is implemented in `save_data_sheets` in [](/src/rpft/converters.py), using the [`ContentIndexParser`](rapidpro.md). However, it its
256+
a content index as (a single) nested JSON. This is implemented in `save_data_sheets` in [/src/rpft/converters.py], using the [`ContentIndexParser`](rapidpro.md). However, it its
257257
own `DataSheet` class via its `to_dict` method. It would be good to unify `DataSheet`
258258
and `RowDataSheet`, and provide this as standalone functionality, once it's decided which meta-data describing the underlying model needs to be stored.
259259

@@ -262,6 +262,8 @@ Below is some (untested) code outlining roughly how this could look like:
262262

263263
```python
264264
from converters import create_sheet_reader
265+
from rpft.parsers.common.model_inference import model_from_headers
266+
import importlib
265267

266268
def convert_to_nested_json(input_file, sheet_format, user_data_model_module_name=None):
267269
"""

src/rpft/converters.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import shutil
44
from pathlib import Path
55

6-
from rpft.parsers.common.model_inference import model_from_headers
76
from rpft.parsers.creation.contentindexparser import ContentIndexParser
87
from rpft.parsers.creation.tagmatcher import TagMatcher
98
from rpft.parsers.sheets import (

0 commit comments

Comments
 (0)