Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 14 additions & 31 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,28 @@ jobs:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v5
name: Configure pip caching
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -e '.[test]'
run: uv sync
- name: Run tests
run: pytest
run: uv run pytest
deploy:
runs-on: ubuntu-latest
needs: [test]
permissions:
id-token: write
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- uses: actions/cache@v5
name: Configure pip caching
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-publish-pip-
- name: Install dependencies
run: |
pip install --upgrade setuptools wheel twine
enable-cache: true

- name: Build
run: uv build
- name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload --verbose dist/*
run: uv publish
21 changes: 6 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,14 @@ jobs:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v5
name: Configure pip caching
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -e '.[test]'
run: uv sync
- name: Run tests
run: |
pytest . --doctest-modules --doctest-glob "README.md"
run: uv run pytest . --doctest-modules --doctest-glob "README.md"
- name: Run type checking
run: |
mypy .
run: uv run mypy .
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Python Frontmatter

[Jekyll](http://jekyllrb.com/)-style YAML front matter offers a useful way to add arbitrary, structured metadata to text documents, regardless of type.
[Front matter](https://docs.github.com/en/contributing/writing-for-github-docs/using-yaml-frontmatter) offers a useful way to add arbitrary, structured metadata to text documents, regardless of type.

This is a small package to load and parse files (or just text) with YAML (or JSON, TOML or other) front matter.

Expand All @@ -11,7 +11,16 @@ This is a small package to load and parse files (or just text) with YAML (or JSO

## Install:

pip install python-frontmatter
```shell
# with pip
pip install python-frontmatter

# or uv
uv add python-frontmatter

# local development, with uv
uv sync
```

## Usage:

Expand Down
18 changes: 9 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@
master_doc = "index"

# General information about the project.
project = u"Python Frontmatter"
copyright = u"2021, Chris Amico"
author = u"Chris Amico"
project = "Python Frontmatter"
copyright = "2021, Chris Amico"
author = "Chris Amico"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u"1.0.0"
version = "1.3.0"
# The full version, including alpha/beta/rc tags.
release = u"1.0.0"
release = "1.3.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -260,8 +260,8 @@
(
master_doc,
"Frontmatter.tex",
u"Frontmatter Documentation",
u"Chris Amico",
"Frontmatter Documentation",
"Chris Amico",
"manual",
)
]
Expand Down Expand Up @@ -303,7 +303,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "frontmatter", u"Frontmatter Documentation", [author], 1)]
man_pages = [(master_doc, "frontmatter", "Frontmatter Documentation", [author], 1)]

# If true, show URL addresses after external links.
#
Expand All @@ -319,7 +319,7 @@
(
master_doc,
"Frontmatter",
u"Frontmatter Documentation",
"Frontmatter Documentation",
author,
"Frontmatter",
"One line description of project.",
Expand Down
34 changes: 28 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@ Python Frontmatter

.. module:: frontmatter

`Jekyll <http://jekyllrb.com/>`__-style YAML front matter offers a
useful way to add arbitrary, structured metadata to text documents,
regardless of type.
`Front matter <https://docs.github.com/en/contributing/writing-for-github-docs/using-yaml-frontmatter>`__
offers a useful way to add arbitrary, structured metadata to text
documents, regardless of type.

This is a package to load and parse files (or text strings) with YAML
front matter.
This is a small package to load and parse files (or just text) with YAML
(or JSON, TOML or other) front matter.


Install
--------

::
.. code-block:: shell

# with pip
pip install python-frontmatter

# or uv
uv add python-frontmatter

# local development, with uv
uv sync

Usage
------

Expand Down Expand Up @@ -50,6 +57,16 @@ Or load from text:
>>> with open('tests/yaml/hello-world.txt') as f:
... post = frontmatter.loads(f.read())

If the file has a `Byte-Order Mark <https://en.wikipedia.org/wiki/Byte_order_mark>`__
(BOM), strip it off first. An easy way to do this is by using the
`utf-8-sig <https://docs.python.org/3/library/codecs.html?highlight=utf%208%20sig#module-encodings.utf_8_sig>`__
encoding:

::

>>> with open('tests/yaml/hello-world.txt', encoding="utf-8-sig") as f:
... post = frontmatter.load(f)

Access content:

::
Expand Down Expand Up @@ -116,6 +133,11 @@ Or write to a file (or file-like object):
---
Well, hello there, world.

For more examples, see files in the ``tests/`` directory. Each sample
file has a corresponding ``.result.json`` file showing the expected
parsed output. See also the ``examples/`` directory, which covers more
ways to customize input and output.


.. toctree::
:maxdepth: 2
Expand Down
50 changes: 50 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[project]
name = "python-frontmatter"
version = "1.3.0"
description = "Parse and manage posts with YAML (or other) frontmatter"
readme = "README.md"
authors = [{ name = "Chris Amico", email = "eyeseast@gmail.com" }]
requires-python = ">=3.10"
dependencies = ["PyYAML"]
license = "MIT"
license-files = ["LICENSE"]
keywords = ["frontmatter"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
[project.urls]
repository = "https://github.com/eyeseast/python-frontmatter"
issues = "https://github.com/eyeseast/python-frontmatter/issues"
documentation = "http://python-frontmatter.rtfd.io"

[project.optional-dependencies]
test = ["pytest", "toml", "pyaml", "mypy", "types-PyYAML", "types-toml"]
docs = ["sphinx"]
toml = ["toml"]

[dependency-groups]
dev = [
"pytest",
"toml",
"pyaml",
"mypy",
"types-PyYAML",
"types-toml",
"sphinx",
]


[build-system]
requires = ["uv_build>=0.11.15,<0.12"]
build-backend = "uv_build"

[tool.uv.build-backend]
module-root = ""
module-name = "frontmatter"
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

51 changes: 0 additions & 51 deletions setup.py

This file was deleted.

Loading
Loading