docs: Added pickle generator

pull/8960/head
Daniel Mensinger 3 years ago
parent 2b482e39a9
commit 955a29a92d
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 26
      docs/refman/generatorpickle.py
  2. 5
      docs/refman/main.py

@ -0,0 +1,26 @@
# Copyright 2021 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pickle
from pathlib import Path
from .generatorbase import GeneratorBase
from .model import ReferenceManual
class GeneratorPickle(GeneratorBase):
def __init__(self, manual: ReferenceManual, outpath: Path) -> None:
self.out = outpath
super().__init__(manual)
def generate(self) -> None:
self.out.write_bytes(pickle.dumps(self.manual))

@ -23,13 +23,15 @@ from .loaderyaml import LoaderYAML
from .generatorbase import GeneratorBase from .generatorbase import GeneratorBase
from .generatorprint import GeneratorPrint from .generatorprint import GeneratorPrint
from .generatorpickle import GeneratorPickle
meson_root = Path(__file__).absolute().parents[2] meson_root = Path(__file__).absolute().parents[2]
def main() -> int: def main() -> int:
parser = argparse.ArgumentParser(description='Meson reference manual generator') 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'], help='Information loader backend')
parser.add_argument('-g', '--generator', type=str, choices=['print'], required=True, help='Generator backend') parser.add_argument('-g', '--generator', type=str, choices=['print', 'pickle', 'md'], required=True, help='Generator backend')
parser.add_argument('-o', '--out', type=Path, required=True, help='Output directory for generated files')
parser.add_argument('--depfile', type=Path, default=None, help='Set to generate a depfile') 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') parser.add_argument('--force-color', action='store_true', help='Force enable colors')
args = parser.parse_args() args = parser.parse_args()
@ -46,6 +48,7 @@ def main() -> int:
generators: T.Dict[str, T.Callable[[], GeneratorBase]] = { generators: T.Dict[str, T.Callable[[], GeneratorBase]] = {
'print': lambda: GeneratorPrint(refMan), 'print': lambda: GeneratorPrint(refMan),
'pickle': lambda: GeneratorPickle(refMan, args.out),
} }
generator = generators[args.generator]() generator = generators[args.generator]()

Loading…
Cancel
Save