[docs]classBaseJsonToMarkdownGenerator(ABC):""" Base JSON to Markdown Generator class """def__init__(self,full_schema,data_path,doc_out_dir,markdown_generator=None):""" Args: full_schema (Dict): Full schema file as dictionary data_path (str | os.PathLike): Path to data folder for any relative file paths doc_out_dir (str | os.PathLike): Path to documentation file output folder for any relative file paths markdown_generator (MarkdownGenerator, optional): MarkdownGenerator class. Defaults to None. """
ifnotmarkdown_generator:self.md=MarkdownGenerator()def_resolve_internal_ref(self,ref):"""Resolves a $ref in the schema (only internal refs supported). Args: ref (str): Reference string of format #/$<reftitle>/<refname> Returns: ref_schema (Dict): Data Properties from reference schema as dictionary """parts=ref.strip("#/").split("/")ref_schema=self.full_schemaforpartinparts:ref_schema=ref_schema.get(part,{})returnref_schema@abstractmethod
[docs]defgenerate(self,json_data,generate_toc=False):"""Top level function to process entire dict to markdown text Args: json_data (Dict): Json data as dictionary generate_toc (bool, Optional): Generate table of contents bool. Defaults to False. Returns: markdown_txt (str): Markdown text """pass