Skip to content

Commit 907308c

Browse files
committed
Fix Markdown warnings
- Remove trailing whitespaces - Ensure one blank line before and after headings/lists - Enforce one H1 heading in a document, the rest will be H2, H3, etc. - Standardize the use of bullet markup (using all `-`, instead of mixing `-` and `*`) Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
1 parent a25937f commit 907308c

File tree

3 files changed

+143
-107
lines changed

3 files changed

+143
-107
lines changed

CONTRIBUTING.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ intention prior to creating a patch.
1515

1616
## Development process
1717

18-
We use the GitHub flow that is described here: https://guides.github.com/introduction/flow/
18+
We use the GitHub flow that is described here: <https://guides.github.com/introduction/flow/>
1919

2020
Here's the process to make changes to the codebase:
2121

@@ -30,15 +30,19 @@ Here's the process to make changes to the codebase:
3030
and optionally follow the further steps described to sync your fork and the original repository.
3131

3232
4. Create a new branch in your fork and set up environment:
33+
3334
```sh
3435
git checkout -b fix-or-improve-something
3536
python -m venv ./venv
3637
./venv/bin/activate
3738
pip install -e ".[development]"
3839
```
39-
Note: By using the group `[development]` for the installation, all dependencies (including optional ones) will be
40-
installed. This way we make sure that all tests are executed.
40+
41+
Note: By using the group `[development]` for the installation, all dependencies (including optional ones) will be
42+
installed. This way we make sure that all tests are executed.
43+
4144
5. Make some changes and commit them to the branch:
45+
4246
```sh
4347
git commit --signoff -m 'description of my changes'
4448
```
@@ -49,46 +53,53 @@ Here's the process to make changes to the codebase:
4953
of [the Developer Certificate of Origin](https://developercertificate.org/). Git has utilities for signing off on
5054
commits: `git commit -s` or `--signoff` signs a current commit, and `git rebase --signoff <revision-range>`
5155
retroactively signs a range of past commits.
56+
5257
6. Test your changes:
58+
5359
```sh
5460
pytest -vvs # in the repo root
5561
```
5662

57-
7. Check your code style. When opening a pull request, your changes will automatically be checked with `isort`, `black`
58-
and `flake8` to make sure your changes fit with the rest of the code style.
63+
7. Check your code style. When opening a pull request, your changes will automatically be checked with `isort`, `black`
64+
and `flake8` to make sure your changes fit with the rest of the code style.
65+
5966
```sh
6067
# run the following commands in the repo root
61-
isort src tests
68+
isort src tests
6269
black src tests
63-
flake8 src tests
70+
flake8 src tests
6471
```
65-
`black` and `isort` will automatically format the code and sort the imports. The configuration for these linters
72+
73+
`black` and `isort` will automatically format the code and sort the imports. The configuration for these linters
6674
can be found in the `pyproject.toml`. `flake8` lists all problems found which then need to be resolved manually.
6775
The configuration for the linter can be found in the `.flake8` file.
6876

6977
8. Push the branch to your fork on GitHub:
78+
7079
```sh
7180
git push origin fix-or-improve-something
7281
```
82+
7383
9. Make a pull request on GitHub.
7484
10. Continue making more changes and commits on the branch, with `git commit --signoff` and `git push`.
7585
11. When done, write a comment on the PR asking for a code review.
7686
12. Some other developer will review your changes and accept your PR. The merge should be done with `rebase`, if
7787
possible, or with `squash`.
7888
13. The temporary branch on GitHub should be deleted (there is a button for deleting it).
7989
14. Delete the local branch as well:
90+
8091
```sh
8192
git checkout master
8293
git pull -p
8394
git branch -a
8495
git branch -d fix-or-improve-something
8596
```
8697

87-
# How to run tests
98+
## How to run tests
8899

89100
The tests framework is using pytest:
90101

91-
```
102+
```sh
92103
pip install pytest
93104
pytest -vvs
94105
```

DOCUMENTATION.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
# Code architecture documentation
22

33
## Package Overview
4+
45
Beneath the top-level package `spdx_tools` you will find three sub-packages:
6+
57
- `spdx`, which contains the code to create, parse, write and validate SPDX documents of versions 2.2 and 2.3
68
- `spdx3`, which will contain the same feature set for versions 3.x once they are released
79
- `common`, which contains code that is shared between the different versions, such as type-checking and `spdx_licensing`.
810

911
## `spdx`
12+
1013
The `spdx` package contains the code dealing with SPDX-2 documents.
1114
The subpackages serve the purpose to divide the code into logically independent chunks. Shared code can be found in the top-level modules here.
1215
`model`, `parser`, `validation` and `writer` constitute the four main components of this library and are further described below.
1316
`clitools` serves as the entrypoint for the command `pyspdxtools`.
1417
`jsonschema` and `rdfschema` contain code specific to the corresponding serialization format.
1518

1619
### `model`
20+
1721
The internal data model closely follows the [official SPDX-2.3 specification](https://spdx.github.io/spdx-spec/v2.3/).
1822

1923
Entrypoint to the model is the `Document` class, which has the following attributes:
24+
2025
- `creation_info`: a single instance of the `CreationInfo` class
2126
- `packages`: a list of `Package` objects
2227
- `files`: a list of `File` objects
@@ -35,6 +40,7 @@ A custom extension of the `@dataclass` annotation is used that is called `@datac
3540
Apart from all the usual `dataclass` functionality, this implements fields of a class as properties with their own getter and setter methods.
3641
This is used in particular to implement type checking when properties are set.
3742
Source of truth for these checks are the attribute definitions at the start of the respective class that must specify the correct type hint.
43+
3844
The `beartype` library is used to check type conformity (`typeguard` was used in the past but has been replaced since due to performance issues).
3945
In case of a type mismatch a `TypeError` is raised. To ensure that all possible type errors are found during the construction of an object,
4046
a custom `__init__()` that calls `check_types_and_set_values()` is part of every class.
@@ -43,26 +49,31 @@ This function tries to set all values provided by the constructor and collects a
4349
For the SPDX values `NONE` and `NOASSERTION` the classes `SpdxNone` and `SpdxNoAssertion` are used, respectively. Both can be instantiated without any arguments.
4450

4551
### `parser`
52+
4653
The parsing and writing modules are split into subpackages according to the serialization formats: `json`, `yaml`, `xml`, `tagvalue` and `rdf`.
4754
As the first three share the same tree structure that can be parsed into a dictionary, their shared logic is contained in the `jsonlikedict` package.
4855
One overarching concept of all parsers is the goal of dealing with parsing errors (like faulty types or missing mandatory fields) as long as possible before failing.
4956
Thus, the `SPDXParsingError` that is finally raised collects as much information as possible about all parsing errors that occurred.
5057

5158
#### `tagvalue`
59+
5260
Since Tag-Value is an SPDX-specific format, there exist no readily available parsers for it.
53-
This library implements its own deserialization code using the `ply` library's `lex` module for lexing and the `yacc` module for parsing.
61+
This library implements its own deserialization code using the `ply` library's `lex` module for lexing and the `yacc` module for parsing.
5462

5563
#### `rdf`
64+
5665
The `rdflib` library is used to deserialize RDF graphs from XML format.
57-
The graph is then being parsed and translated into the internal data model.
66+
The graph is then being parsed and translated into the internal data model.
5867

5968
#### `json`, `yaml`, `xml`
69+
6070
In a first step, all three of JSON, YAML and XML formats are deserialized into a dictionary representing their tree structure.
6171
This is achieved via the `json`, `yaml` and `xmltodict` packages, respectively.
6272
Special note has to be taken in the XML case which does not support lists and numbers.
6373
The logic concerning the translation from these dicts to the internal data model can be found in the `jsonlikedict` package.
6474

6575
### `writer`
76+
6677
For serialization purposes, only non-null fields are written out.
6778
All writers expect a valid SPDX document from the internal model as input.
6879
To ensure this is actually the case, the standard behaviour of every writer function is to call validation before the writing process.
@@ -71,18 +82,21 @@ Also by default, all list properties in the model are scanned for duplicates whi
7182
This can be disabled by setting the `drop_duplicates` boolean to false.
7283

7384
#### `tagvalue`
85+
7486
The ordering of the tags follows the [example in the official specification](https://github.com/spdx/spdx-spec/blob/development/v2.3.1/examples/SPDXTagExample-v2.3.spdx).
7587

7688
#### `rdf`
89+
7790
The RDF graph is constructed from the internal data model and serialized to XML format afterward, using the `rdflib` library.
7891

7992
#### `json`, `yaml`, `xml`
93+
8094
As all three of JSON, YAML and XML formats share the same tree structure, the first step is to generate the dictionary representing that tree.
8195
This is achieved by the `DocumentConverter` class in the `jsonschema` package.
8296
Subsequently, the dictionary is serialized using the `json`, `yaml` and `xmltodict` packages, respectively.
8397

84-
8598
### `validation`
99+
86100
The `validation` package takes care of all nonconformities with the SPDX specification that are not due to incorrect typing.
87101
This mainly includes checks for correctly formatted strings or the actual existence of references SPDXIDs.
88102
Entrypoint is the `document_validator` module with the `validate_full_spdx_document()` function.
@@ -93,6 +107,7 @@ Validation and reference checking of SPDXIDs (and possibly external document ref
93107
For the validation of license expressions we utilise the `license-expression` library's `validate` and `parse` functions, which take care of checking license symbols against the [SPDX license list](https://spdx.org/licenses/).
94108

95109
Invalidities are captured in instances of a custom `ValidationMessage` class. This has two attributes:
110+
96111
- `validation_message` is a string that describes the actual problem
97112
- `validation_context` is a `ValidationContext` object that helps to pinpoint the source of the problem by providing the faulty element's SPDXID (if it has one), the parent SPDXID (if that is known), the element's type and finally the full element itself.
98113
It is left open to the implementer which of this information to use in the following evaluation of the validation process.
@@ -101,6 +116,7 @@ Every validation function returns a list of `ValidationMessage` objects, which a
101116
That is, if an empty list is returned, the document is valid.
102117

103118
## `spdx3`
119+
104120
Due to the SPDX-3 model still being in development, this package is still a work in progress.
105121
However, as the basic building blocks of parsing, writing, creation and validation are still important in the new version,
106122
the `spdx3` package is planned to be structured similarly to the `spdx` package.

0 commit comments

Comments
 (0)