docs: Added pickle RefMan loader

pull/9377/head
Daniel Mensinger 3 years ago
parent f06cdf0606
commit ba93dd20ca
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 22
      docs/refman/loaderpickle.py
  2. 7
      docs/refman/main.py

@ -0,0 +1,22 @@
# SPDX-License-Identifer: Apache-2.0
# Copyright 2021 The Meson development team
from pathlib import Path
import pickle
from .loaderbase import LoaderBase
from .model import ReferenceManual
class LoaderPickle(LoaderBase):
def __init__(self, in_file: Path) -> None:
super().__init__()
self.in_file = in_file
def load_impl(self) -> ReferenceManual:
res = pickle.loads(self.in_file.read_bytes())
assert isinstance(res, ReferenceManual)
return res
# Assume that the pickled data is OK and skip validation
def load(self) -> ReferenceManual:
return self.load_impl()

@ -19,6 +19,7 @@ import typing as T
from mesonbuild import mlog
from .loaderbase import LoaderBase
from .loaderpickle import LoaderPickle
from .loaderyaml import LoaderYAML
from .generatorbase import GeneratorBase
@ -30,10 +31,11 @@ meson_root = Path(__file__).absolute().parents[2]
def main() -> int:
parser = argparse.ArgumentParser(description='Meson reference manual generator')
parser.add_argument('-l', '--loader', type=str, default='yaml', choices=['yaml'], help='Information loader backend')
parser.add_argument('-l', '--loader', type=str, default='yaml', choices=['yaml', 'pickle'], help='Information loader backend')
parser.add_argument('-g', '--generator', type=str, choices=['print', 'pickle', 'md'], required=True, help='Generator backend')
parser.add_argument('-s', '--sitemap', type=Path, default=meson_root / 'docs' / 'sitemap.txt', help='Path to the input sitemap.txt')
parser.add_argument('-o', '--out', type=Path, required=True, help='Output directory for generated files')
parser.add_argument('-i', '--input', type=Path, default=meson_root / 'docs' / 'yaml', help='Input path for the selected loader')
parser.add_argument('--link-defs', type=Path, help='Output file for the MD generator link definition file')
parser.add_argument('--depfile', type=Path, default=None, help='Set to generate a depfile')
parser.add_argument('--force-color', action='store_true', help='Force enable colors')
@ -44,7 +46,8 @@ def main() -> int:
mlog.colorize_console = lambda: True
loaders: T.Dict[str, T.Callable[[], LoaderBase]] = {
'yaml': lambda: LoaderYAML(meson_root / 'docs' / 'yaml'),
'yaml': lambda: LoaderYAML(args.input),
'pickle': lambda: LoaderPickle(args.input),
}
loader = loaders[args.loader]()

Loading…
Cancel
Save