|
| 1 | +# Organization |
| 2 | + |
| 3 | +The snooty parser has the following key parts: |
| 4 | + |
| 5 | +* Frontends |
| 6 | + * `main.py` |
| 7 | + * `language_server.py` |
| 8 | +* Parser |
| 9 | + * `parser.py` |
| 10 | + * `rstparser.py` |
| 11 | + * `gizaparser/` |
| 12 | +* Types & Tools |
| 13 | + * `flutter.py` |
| 14 | + * `types.py` |
| 15 | + * `util.py` |
| 16 | + |
| 17 | +## Frontends |
| 18 | + |
| 19 | +Snooty *frontends* instantiate a parser and use it to interact with |
| 20 | +reStructuredText and YAML files, and to create output artifacts and |
| 21 | +report diagnostics. |
| 22 | + |
| 23 | +These frontends instantiate a `parser.Project` object. |
| 24 | + |
| 25 | +### `main.py` |
| 26 | + |
| 27 | +`main.py` defines the main command-line Snooty interface. |
| 28 | + |
| 29 | +### `language_server.py` |
| 30 | + |
| 31 | +`language_server.py` defines a |
| 32 | +[Language Server](https://microsoft.github.io/language-server-protocol/specification) |
| 33 | +for use with IDEs such as Visual Studio Code. |
| 34 | + |
| 35 | +## Parser |
| 36 | + |
| 37 | +The `parser.Project` class is the main frontend-agnostic interface to |
| 38 | +Snooty. It reads a `snooty.toml` file to configure the project, and |
| 39 | +parses each file with `rstparser.Parser`. |
| 40 | + |
| 41 | +`rstparser.Parser` is responsible for transforming input reStructuredText artifacts |
| 42 | +(.rst & .txt) into our JSON AST format. It instantiates a visitor object |
| 43 | +(unnecessarily parameterized; it's always `parser.JSONVisitor`); creates |
| 44 | +a docutils parser; passes the markup into it; and uses the visitor to |
| 45 | +create the AST. The parent `parser.Project` then calls the configured |
| 46 | +callbacks to notify the frontend of the parsed page. |
| 47 | + |
| 48 | +The parser transforms Giza-style YAML files using the `gizaparser` |
| 49 | +package. This uses the `flutter` library to deserialize the YAML files |
| 50 | +into Python classes, and check types to ensure there are no errors. |
| 51 | + |
| 52 | +### `parser.py` |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +### `rstparser.py` |
| 57 | + |
| 58 | +`docutils`-interfacing components of the parser. |
| 59 | + |
| 60 | +### `gizaparser/` |
| 61 | + |
| 62 | +Each module in this package contains the infrastructure to parse a category |
| 63 | +of Giza YAML file. The `gizaparser.nodes` module contains generally-applicable |
| 64 | +helper classes. |
| 65 | + |
| 66 | +## Types & Tools |
| 67 | +### `flutter.py` |
| 68 | +### `types.py` |
| 69 | +### `util.py` |
| 70 | + |
| 71 | + |
| 72 | +# Problem Areas |
| 73 | + |
| 74 | +* Transforming docutils nodes into our AST (parser.JSONVisitor) is |
| 75 | + currently a wretched mess. |
| 76 | +* Flutter is currently a fork to add support for line numbers. We need to |
| 77 | + figure out a cleaner way of doing this so we can merge it into the |
| 78 | + upstream codebase. |
0 commit comments