Skip to content

Commit b8d308c

Browse files
authored
Improve README.md (#11)
This updates the `README.md` reflecting the recent refactor of how the `BibTeXEntry.entry_type` is parsed. Furthermore, we link the PyPI page of the project. Fixes #8
1 parent 588d13a commit b8d308c

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ It is however relatively easy to define your own [custom ruleset](#advanced-cust
2828
## How to use:
2929
First we need to install the tool, I recommend to use [pipx](https://github.com/pypa/pipx) for that:
3030
```commandline
31-
pipx install .
31+
pipx install bibtex_linter
3232
```
3333

34+
You can find the package on PyPI [here](https://pypi.org/project/bibtex-linter/).
35+
3436
### Basic Usage
3537
Then you can call the script the following way:
3638
```commandline
@@ -45,23 +47,24 @@ The script will parse the file, perform the checks and print out the results.
4547
4648
### Advanced: Custom Rulesets
4749

50+
It is also possible to define your own rules inside a Python file.
51+
4852
> [!warning]
4953
> Custom rulesets are plain Python code and will be executed on your machine.
5054
> If you wouldn't trust running `python3 my_rules.py`, you shouldn't use it with `bibtex_linter`.
5155
> **Only use rulesets from sources you trust!**
5256
53-
It is also possible to define your own rules inside a Python file.
54-
Let's call it `my_own_rules.py`.
57+
Let's call our custom rule file `my_own_rules.py`.
5558
Creating your own rule is as simple as:
5659

5760
```Python
5861
from typing import List
5962

60-
from bibtex_linter.parser import BibTeXEntry, EntryType
63+
from bibtex_linter.parser import BibTeXEntry
6164
from bibtex_linter.verification import linter_rule
6265

6366

64-
@linter_rule(entry_type=EntryType.ARTICLE)
67+
@linter_rule(entry_type="article")
6568
def check_article(entry: BibTeXEntry) -> List[str]:
6669
"""
6770
Check that a `BibTeXEntry` has a nonempty `author` field.
@@ -78,10 +81,11 @@ As you can see, we created a method and designated that it is a linter rule by u
7881
The method needs to have a specific interface:
7982
It needs to take the `BibTeXEntry` to be checked as input argument, and it needs to return a List of strings explaining
8083
the rule violations for that `BibTeXEntry`.
81-
If there are no rule violations, it should return an empty list.
84+
If there are no rule violations, it should return an empty list.
8285

83-
This rule only gets executed for entries of the `ARTICLE` type, as specified by the decorator argument.
86+
This rule only gets executed for entries of the `article` type, as specified by the decorator argument.
8487
If we left the `entry_type` argument empty, this check would be executed on all entries.
88+
Read section [Entry Type](#entry-type) for some notes on how the `entry_type` is parsed to string.
8589

8690
For more inspiration on what you could define as your custom rules, have a look into `bibtex_linter/default_rules.py`.
8791
After defining the rules in `my_own_rules.py`, we can execute them on a BibTeX file like this:
@@ -130,3 +134,10 @@ The entry type specifies the available fields and is written behind the `@` and
130134
@conference{...}
131135
@online{...}
132136
```
137+
138+
> [!note]
139+
> Our convention is to use small letter entry types.
140+
> This means, the [parser](bibtex_linter/parser.py) will automatically parse `@ARTICLE` to
141+
> `BibTeXEntry.entry_type = "article"`.
142+
> Furthermore, the parser converts some well-known aliases of `entry_types` into a standard form.
143+
> Check the `RESOLVE_ENTRY_TYPE_ALIAS` `Dict` in the [parser.py](bibtex_linter/parser.py).

0 commit comments

Comments
 (0)