def common_md(): print(f"Using docs directory: {DOCS_DIR}") print(f"Using ops docs directory: {OP_DOCS_DIR}") print() op_table_template = env.get_template("op_table.jinja2.md") op_extended_template = env.get_template("op_extended.jinja2.md") output = "" output += Path(DOCS_DIR / "whats_new.md").read_text() + "\n\n" output += Path(DOCS_DIR / "modes.md").read_text() + "\n\n" output += Path(DOCS_DIR / "ops.md").read_text() + "\n\n" all_ops = set(list_ops()) | set(list_mods()) all_ops_dict = {} ops_with_docs = set() for section in OPS_SECTIONS: md_file = Path(OP_DOCS_DIR, section + ".md") toml_file = Path(OP_DOCS_DIR, section + ".toml") output += "\\newpage\n" if md_file.exists() and md_file.is_file(): print(f"Reading {md_file}") output += md_file.read_text() + "\n\n" output += "\n" if toml_file.exists() and toml_file.is_file(): print(f"Reading {toml_file}") extended = [] # n.b. Python 3.6 dicts maintain insertion order ops = toml.loads(toml_file.read_text()) validate_toml(ops) deep_merge_dict(ops, all_ops_dict) for key in ops: if key not in all_ops: print(f" - WARNING: unknown {key}") ops_with_docs.add(key) if "aliases" in ops[key]: ops_with_docs |= set(ops[key]["aliases"]) if "description" in ops[key]: render = op_extended_template.render(name=key, **ops[key]) extended.append((key, render)) output += op_table_template.render(ops=ops.values()) output += "\n" output += "\n".join([e[1] for e in extended]) + "\n\n" output += Path(DOCS_DIR / "advanced.md").read_text() + "\n\n" output += "\\appendix\n\n" output += "# Alphabetical list of OPs and MODs\n\n" sorted_ops = [kv[1] for kv in sorted(all_ops_dict.items())] output += op_table_template.render(ops=sorted_ops) output += "# Missing documentation\n\n" missing_ops = all_ops - ops_with_docs output += ", ".join([f"`{o}`" for o in sorted(missing_ops)]) + "\n\n" output += Path(ROOT_DIR / "CHANGELOG.md").read_text() + "\n\n" return output
def common_md(): print(f"Using docs directory: {DOCS_DIR}") print(f"Using ops docs directory: {OP_DOCS_DIR}") print() op_table_template = env.get_template("op_table.jinga2.md") op_extended_template = env.get_template("op_extended.jinga2.md") output = "" output += Path(DOCS_DIR / "modes.md").read_text() output += Path(DOCS_DIR / "ops.md").read_text() all_ops = set(list_ops()) | set(list_mods()) all_ops_dict = {} ops_with_docs = set() for section in OPS_SECTIONS: md_file = Path(OP_DOCS_DIR, section + ".md") toml_file = Path(OP_DOCS_DIR, section + ".toml") output += "\\newpage\n" if md_file.exists() and md_file.is_file(): print(f"Reading {md_file}") output += md_file.read_text() output += "\n" if toml_file.exists() and toml_file.is_file(): print(f"Reading {toml_file}") extended = [] # n.b. Python 3.6 dicts maintain insertion order ops = toml.loads(toml_file.read_text()) validate_toml(ops) deep_merge_dict(ops, all_ops_dict) for key in ops: if key not in all_ops: print(f" - WARNING: unknown {key}") ops_with_docs.add(key) if "aliases" in ops[key]: ops_with_docs |= set(ops[key]["aliases"]) if "description" in ops[key]: render = op_extended_template.render(name=key, **ops[key]) extended.append((key, render)) output += op_table_template.render(ops=ops.values()) output += "\n" output += "\n".join([e[1] for e in extended]) + "\n\n" output += "\\appendix\n\n" output += "# Alphabetical list of OPs and MODs\n\n" sorted_ops = [kv[1] for kv in sorted(all_ops_dict.items())] output += op_table_template.render(ops=sorted_ops) output += "# Missing documentation\n\n" missing_ops = all_ops - ops_with_docs output += ", ".join([f"`{o}`" for o in sorted(missing_ops)]) + "\n\n" output += Path(ROOT_DIR / "CHANGELOG.md").read_text() + "\n\n" return output
def common_md(): print(f"Pandoc version: {pypandoc.get_pandoc_version()}") print(f"Using docs directory: {DOCS_DIR}") print(f"Using ops docs directory: {OP_DOCS_DIR}") print() html_op_list_template = env.get_template("html_op_list.jinja2.md") html_op_table_template = env.get_template("html_op_table.jinja2.md") pdf_op_table_template = env.get_template("pdf_op_table.jinja2.md") pdf_op_extended_template = env.get_template("pdf_op_extended.jinja2.md") intro = "" intro += Path(DOCS_DIR / "intro.md") \ .read_text().replace("VERSION", TT_VERSION["tag"][1:]) + "\n\n" intro += Path(DOCS_DIR / "whats_new.md").read_text() + "\n\n" intro += Path(DOCS_DIR / "quickstart.md").read_text() + "\n\n" intro += Path(DOCS_DIR / "keys.md").read_text() + "\n\n" intro += Path(DOCS_DIR / "ops.md").read_text() + "\n\n" all_ops = set(list_ops()) | set(list_mods()) all_ops_dict = {} ops_with_docs = set() pdf_ops_section = "" html_ops_section = "" for section in OPS_SECTIONS: md_file = Path(OP_DOCS_DIR, section + ".md") toml_file = Path(OP_DOCS_DIR, section + ".toml") pdf_ops_section += "\\newpage\n" html_ops_section += "\\newpage\n" if md_file.exists() and md_file.is_file(): print(f"Reading {md_file}") pdf_ops_section += md_file.read_text() + "\n\n" html_ops_section += md_file.read_text() + "\n\n" if toml_file.exists() and toml_file.is_file(): print(f"Reading {toml_file}") extended = [] # n.b. Python 3.6 dicts maintain insertion order ops = toml.loads(toml_file.read_text()) validate_toml(ops) deep_merge_dict(ops, all_ops_dict) for key in ops: if key not in all_ops: print(f" - WARNING: unknown {key}") ops_with_docs.add(key) if "aliases" in ops[key]: ops_with_docs |= set(ops[key]["aliases"]) if "description" in ops[key]: render = pdf_op_extended_template.render(name=key, **ops[key]) extended.append((key, render)) pdf_ops_section += pdf_op_table_template.render(ops=ops.values()) pdf_ops_section += "\n" pdf_ops_section += "\n".join([e[1] for e in extended]) + "\n\n" html_ops_section += html_op_list_template.render(ops=ops.values()) advanced = Path(DOCS_DIR / "advanced.md").read_text() + "\n\n" pdf_alpha_ops = "\\appendix\n\n" pdf_alpha_ops += "# Alphabetical list of OPs and MODs\n\n" html_alpha_ops = pdf_alpha_ops sorted_ops = [kv[1] for kv in sorted(all_ops_dict.items())] pdf_alpha_ops += pdf_op_table_template.render(ops=sorted_ops) html_alpha_ops += html_op_table_template.render(ops=sorted_ops) missing = "\n\n# Missing documentation\n\n" missing += ", ".join([f"`{o}`" for o in sorted(all_ops - ops_with_docs)]) + "\n\n" changelog = Path(ROOT_DIR / "CHANGELOG.md").read_text() + "\n\n" pdf_output = intro + pdf_ops_section + advanced + pdf_alpha_ops + missing + changelog html_output = intro + html_ops_section + advanced + html_alpha_ops + missing + changelog return {"pdf": pdf_output, "html": html_output}