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
11 changes: 9 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Build Standard

on:
pull_request:
push:
branches:
- main
- "[0-9]+.[0-9]+-rc"

permissions:
contents: read
Expand All @@ -18,7 +22,10 @@ jobs:
- uses: astral-sh/setup-uv@v7
with:
version: "0.12.5"
- name: Test documentation redirects
enable-cache: true
- name: Test documentation checks
run: uv run --frozen python -m unittest discover -s tests
- name: Build Standard with warnings as errors
run: uv run --frozen sphinx-build -W -c . docs/standard build
run: uv run --frozen sphinx-build -W --keep-going -c . docs/standard build
- name: Check specification examples
run: uv run --frozen scripts/check-examples.py
7 changes: 6 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
def _flag_expandable_toc_entries(app, pagename, templatename, context, doctree):
for toc in context.get("toctree_data", []):
for entry in toc["entries"]:
sections = app.env.toc_dict.get(entry["name"], {}).get("sections")
sections = app.env.toc_dict.get(entry["name"], {}).get("sections") or []
# A page without subsections gets its own title as the only
# section, which would list the page under itself.
if len(sections) == 1 and sections[0]["title"] == entry["title"]:
sections = []
entry["children"] = []
entry["has_children"] = bool(sections)


Expand Down
9 changes: 9 additions & 0 deletions docs/standard/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Full example
============

This example uses every key, including deprecated keys. The English
description uses all available fields. The Italian description uses
only the fields required for each language.

.. literalinclude:: example/publiccode.yml
:language: yaml
171 changes: 94 additions & 77 deletions docs/standard/example/publiccode.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,123 @@
publiccodeYmlVersion: "0"
publiccodeYmlVersion: "1"

name: Office Suite
name: Firefax
url: https://example.com/firefax.git
landingURL: https://example.com/firefax
softwareType: standalone/desktop
platforms:
- linux
- windows
- mac
developmentStatus: stable
softwareVersion: "2.3"
releaseDate: "2026-03-15"
logo: img/logo.svg
applicationSuite: MegaProductivitySuite
url: "https://example.com/office-suite.git"
landingURL: "https://example.com/office-suite"
isBasedOn:
- "https://example.com/document-editor.git"
softwareVersion: "1.0"
releaseDate: "2017-04-15"
logo: img/logo.svg

platforms:
- android
- ios

categories:
- content-management
- office

roadmap: "https://example.com/office-suite/roadmap"

developmentStatus: development

softwareType: "standalone/desktop"

intendedAudience:
scope:
- science-and-technology
countries:
- IT
- DE
- https://example.com/openfax.git
roadmap: https://example.com/firefax/roadmap

description:
en:
localisedName: Office Suite
shortDescription: >
This description can have a maximum 150
characters long. We should not fill the
remaining space with "Lorem Ipsum". End

localisedName: Firefax
shortDescription: Send and receive faxes from the desktop
longDescription: >
Very long description of this software, also split
on multiple rows. You should note what the software
is and why one should need it.
It can also contain some basic Markdown.
Firefax lets you send and receive faxes from a desktop computer
without a fax machine. You can search received faxes in an archive,
schedule outgoing faxes and track their delivery.

documentation: "https://read.the.documentation/office-suite/v1.0"
apiDocumentation: "https://read.the.api.doc/office-suite/v1.0"

Offices that exchange documents by fax can keep those documents
in one archive and replace their fax machines.
documentation: https://example.com/firefax/docs
apiDocumentation: https://example.com/firefax/api
features:
- Very important feature
- Will run without a problem
- Has zero bugs
- Solves all the problems of the world
- Send and receive faxes without a fax machine
- Search the archive of received faxes
- Schedule outgoing faxes
- Track the delivery of every fax
- Sign outgoing faxes digitally
screenshots:
- img/sshot1.jpg
- img/sshot2.jpg
- img/sshot3.jpg
- img/screenshots/inbox.png
- img/screenshots/compose.png
videos:
- https://www.youtube.com/watch?v=xxxxxxxxxxx
awards:
- 1st Price Software of the year
- Public Sector Software Award 2025
en-GB:
shortDescription: Send and receive faxes from your computer

legal:
license: AGPL-3.0-or-later
mainCopyrightOwner: City of Chicago
license: EUPL-1.2 OR AGPL-3.0-or-later
mainCopyrightOwner: Example City Council

maintenance:
type: "contract"
organisation:
uri: https://example.com/organisations/example-city-council
name: Example City Council

maintenance:
type: contract
contractors:
- name: "Fornitore Privato SPA"
email: "dario.bianchi@fornitore.it"
website: "https://privatecompany.com"
until: "2019-01-01"

- name: Example Software Ltd
until: "2027-12-31"
email: firefax-maintenance@supplier.example.com
website: https://supplier.example.com
contacts:
- name: Francesco Rossi
email: "francesco.rossi@comune.reggioemilia.it"
affiliation: Comune di Reggio Emilia
phone: "+3923113215112"
- name: Jane Doe
email: jane.doe@supplier.example.com
affiliation: Example Software Ltd
phone: "+441234567890"

localisation:
localisationReady: true
availableLanguages:
- en
- it
- en-GB
- fr
- de

dependsOn:
proprietary:
- name: Oracle
versionMin: "11.4"
- name: IBM SoftLayer
hardware:
- name: NFC Reader
optional: true
categories:
- communications
- document-management

supports:
- id: alias:gdpr
- id: alias:eidas
- id: https://eur-lex.europa.eu/eli/dir/2016/2102/oj
- id: alias:gdpr

organisation:
uri: urn:x-italian-pa:c_h501
name: Roma Capitale
intendedAudience:
countries:
- GB
unsupportedCountries:
- US
scope:
- local-authorities

usedBy:
- Example City Council
- Example County Council

fundedBy:
- name: Example City Council
uri: https://example.com/organisations/example-city-council

dependsOn:
open:
- name: PostgreSQL
version: "16"
- name: Ghostscript
versionMin: "10.0"
versionMax: "10.5"
optional: true
proprietary:
- name: Oracle Database
versionMin: "19"
versionMax: "23"
optional: true
- name: Proprietary fax driver
version: "3"
hardware:
- name: Fax modem
versionMin: "1"
versionMax: "2"
optional: true
- name: USB fax adapter
version: "3"
3 changes: 3 additions & 0 deletions docs/standard/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ A minimal ``publiccode.yml``:
.. literalinclude:: example/publiccode.minimal.yml
:language: yaml

The :doc:`full example <example>` uses every key.

.. toctree::
:maxdepth: 2
:hidden:

forks.rst
types.rst
vocabularies.rst
example.rst

Conventions
-----------
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ dependencies = [
"sphinx-polyversion>=2.0.0",
"sphinx-press-theme==0.9.1",
]

[dependency-groups]
dev = [
"pyyaml>=6.0.3",
]
104 changes: 104 additions & 0 deletions scripts/check-examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env python3
"""Check the example files against the keys documented in the spec.

Both examples may use only documented keys, and the full example must
use every one of them, so a key added to the spec without an example
fails the build. The description length limits are checked too.
"""

import re
import sys
from pathlib import Path

import yaml

SPEC = Path("docs/standard/index.rst")
TYPES = Path("docs/standard/types.rst")
MINIMAL = Path("docs/standard/example/publiccode.minimal.yml")
FULL = Path("docs/standard/example/publiccode.yml")

HEADING = re.compile(r"^``([A-Za-z/\[\]]+)``")


def properties(text):
match = re.search(r"^Properties(?: of each item)?:\n", text, re.MULTILINE)
if not match:
return set()
text = text[match.end():]
return set(re.findall(r"^- ``([A-Za-z]+)``", text, re.MULTILINE))


def documented_keys():
types = {}
for section in re.split(r"^\.\. _", TYPES.read_text(), flags=re.MULTILINE)[1:]:
anchor, _, body = section.partition(":")
types[anchor] = properties(body)

lines = SPEC.read_text().splitlines()
headings = []
for index, (line, underline) in enumerate(zip(lines, lines[1:])):
match = HEADING.match(line)
if match and underline and set(underline) <= set("~'"):
headings.append((index, match[1]))

keys = set()
for position, (start, key) in enumerate(headings):
keys.add(key)
end = headings[position + 1][0] if position + 1 < len(headings) else len(lines)
section = "\n".join(lines[start:end])
item_properties = properties(section)
match = re.search(r"array of :ref:`[^`]+ <([^>]+)>`", section)
if match:
item_properties |= types[match[1]]
keys.update(f"{key}/[]/{prop}" for prop in item_properties)
return keys


def used_keys(node, prefix=""):
keys = set()
if isinstance(node, list):
for item in node:
keys |= used_keys(item, prefix + "[]/")
elif isinstance(node, dict):
for key, value in node.items():
path = f"{prefix}{key}"
# The language level is a tag, not a documented key.
if prefix == "description/":
path = "description/[lang]"
else:
keys.add(path)
keys |= used_keys(value, path + "/")
return keys


def check_descriptions(name, data):
errors = []
for lang, texts in data.get("description", {}).items():
short = texts.get("shortDescription", "")
if len(short) > 150 or "\n" in short:
errors.append(f"{name}: description/{lang}/shortDescription must be one line of at most 150 characters")
long = texts.get("longDescription")
if long is not None and not 150 <= len(long) <= 10000:
errors.append(f"{name}: description/{lang}/longDescription is {len(long)} characters, not 150 to 10000")
return errors


def main():
spec = documented_keys()
errors = []
for path in (MINIMAL, FULL):
data = yaml.safe_load(path.read_text())
used = used_keys(data)
for key in sorted(used - spec):
errors.append(f"{path}: {key} is not documented in {SPEC}")
if path == FULL:
for key in sorted(spec - used):
errors.append(f"{path}: {key} is documented but missing from the full example")
errors += check_descriptions(path, data)
for error in errors:
print(error, file=sys.stderr)
return 1 if errors else 0


if __name__ == "__main__":
sys.exit(main())
Loading
Loading