Skip to content

Commit

Permalink
fix: drop title
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Jul 28, 2023
1 parent a77dffe commit 1c0064d
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ repos:
- id: mypy
files: ^(src|tests)
args: [--show-error-codes]
additional_dependencies: [numpy~=1.23.0, pytest, importlib_metadata]
additional_dependencies:
- numpy~=1.23.0
- pytest
- importlib_metadata
- importlib_resources

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
Expand Down
33 changes: 5 additions & 28 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@

import sys

# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


if sys.version_info < (3, 8):
import importlib_metadata as metadata
else:
Expand All @@ -31,7 +21,7 @@
author = "Henry Schreiner, Hans Dembinski, Jim Pivarski"

# The full version, including alpha/beta/rc tags
release = metadata.version("uhi")
version = release = metadata.version("uhi")


# -- General configuration ---------------------------------------------------
Expand All @@ -40,10 +30,13 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"myst_parser",
"sphinx.ext.napoleon",
"sphinx_copybutton",
]

source_suffix = [".rst", ".md"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand All @@ -52,25 +45,9 @@
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_book_theme"

html_baseurl = "https://uhi.readthedocs.io/en/latest/"

html_theme_options = {
"home_page_in_toc": True,
"repository_url": "https://github.com/scikit-hep/uhi",
"use_repository_button": True,
"use_issues_button": True,
"use_edit_page_button": True,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = [] # _static
html_theme = "furo"
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ to plot a histogram, including error bars.
indexing.rst
indexing+.rst
plotting.rst
serialization.md



Expand Down
7 changes: 7 additions & 0 deletions docs/serialization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Serialization

A standard form of serialization is described as follows:

```{literalinclude} ../src/uhi/resources/histogram.json
:language: json
```
37 changes: 25 additions & 12 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import argparse
import re
from pathlib import Path

Expand Down Expand Up @@ -31,22 +32,34 @@ def tests(session):
session.run("pytest", *session.posargs)


@nox.session
def docs(session):
@nox.session(reuse_venv=True)
def docs(session: nox.Session) -> None:
"""
Build the docs. Pass "serve" to serve.
Build the docs. Pass "--serve" to serve.
"""

session.install(".[docs]")
parser = argparse.ArgumentParser()
parser.add_argument("--serve", action="store_true", help="Serve after building")
args, posargs = parser.parse_known_args(session.posargs)

session.install("-e.[docs]")
session.chdir("docs")
session.run("sphinx-build", "-M", "html", ".", "_build")

if session.posargs:
if "serve" in session.posargs:
print("Launching docs at http://localhost:8000/ - use Ctrl-C to quit")
session.run("python", "-m", "http.server", "8000", "-d", "_build/html")
else:
print("Unsupported argument to docs")

session.run(
"sphinx-build",
"-n", # nitpicky mode
"--keep-going", # show all errors
"-T", # full tracebacks
"-b",
"html",
".",
"_build/html",
*posargs,
)

if args.serve:
session.log("Launching docs at http://localhost:8000/ - use Ctrl-C to quit")
session.run("python", "-m", "http.server", "8000", "-d", "_build/html")


@nox.session
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ schema = [
]
docs = [
"sphinx>=4.0",
"sphinx-book-theme>=0.0.40",
"furo",
"sphinx-copybutton>=0.3.1",
"myst-parser",
]
test = [
"pytest>=6",
Expand Down Expand Up @@ -85,6 +86,10 @@ python_version = "3.8"
warn_unused_configs = "true"
strict = true

[[tool.mypy.overrides]]
module = ["fastjsonschema"]
ignore_missing_imports = true

[tool.ruff]
select = [
"E", "F", "W", # flake8
Expand Down
9 changes: 1 addition & 8 deletions src/uhi/resources/histogram.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/scikit-hep/uhi/.json",
"$id": "https://raw.githubusercontent.com/scikit-hep/uhi/henryiii/feat/schema/src/uhi/resources/histogram.json",
"type": "object",
"patternProperties": {
".+": {
"type": "object",
"required": ["axes", "storage"],
"properties": {
"title": { "type": "string" },
"name": { "type": "string" },
"metadata": { "type": "object" },
"axes": {
"type": "array",
Expand Down Expand Up @@ -47,7 +45,6 @@
"overflow": { "type": "boolean" },
"circular": { "type": "boolean" },
"name": { "type": "string" },
"title": { "type": "string" },
"metadata": { "type": "object" }
}
},
Expand All @@ -71,7 +68,6 @@
"overflow": { "type": "boolean" },
"circular": { "type": "boolean" },
"name": { "type": "string" },
"title": { "type": "string" },
"metadata": { "type": "object" }
}
},
Expand All @@ -83,7 +79,6 @@
"categories": { "type": "array", "items": { "type": "string" } },
"flow": { "type": "boolean" },
"name": { "type": "string" },
"title": { "type": "string" },
"metadata": { "type": "object" }
}
},
Expand All @@ -95,7 +90,6 @@
"categories": { "type": "array", "items": { "type": "number" } },
"flow": { "type": "boolean" },
"name": { "type": "string" },
"title": { "type": "string" },
"metadata": { "type": "object" }
}
},
Expand All @@ -105,7 +99,6 @@
"properties": {
"type": { "type": "string", "pattern": "boolean" },
"name": { "type": "string" },
"title": { "type": "string" },
"metadata": { "type": "object" }
}
},
Expand Down
6 changes: 4 additions & 2 deletions src/uhi/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import sys
from pathlib import Path

import fastjsonschema

Expand All @@ -16,8 +17,9 @@
histogram_schema = fastjsonschema.compile(json.load(f))


def validate(path: str) -> None:
with open(path, encoding="utf-8") as f:
def validate(path: str | Path) -> None:
path = Path(path)
with path.open(encoding="utf-8") as f:
example = json.load(f)

histogram_schema(example)
Expand Down

0 comments on commit 1c0064d

Please sign in to comment.