diff --git a/adr_viewer/__init__.py b/adr_viewer/__init__.py index 1f13a29..b4363e9 100644 --- a/adr_viewer/__init__.py +++ b/adr_viewer/__init__.py @@ -1,27 +1,12 @@ -import os from typing import List from click import option, command from adr_viewer.parse import parse_adr, parse_adr_files, Adr -from adr_viewer.render import render_html, AdrTemplateConfig +from adr_viewer.render import render_html, AdrTemplateConfig, generate_content from adr_viewer.server import run_server -def generate_content(adrs: List[Adr], template_dir_override=None, title=None) -> str: - config = AdrTemplateConfig( - project_title=title if title else os.path.basename(os.getcwd()), records=[] - ) - - for index, adr in enumerate(adrs): - adr.index = index - adr.includes_mermaid |= config.include_mermaid - - config.records.append(adr) - - return render_html(config, template_dir_override) - - # fmt: off @command() @option('--adr-path', default='doc/adr/', help='Directory containing ADR files.', show_default=True) diff --git a/adr_viewer/render.py b/adr_viewer/render.py index aa8fdad..e0073c9 100644 --- a/adr_viewer/render.py +++ b/adr_viewer/render.py @@ -1,3 +1,4 @@ +import os from dataclasses import dataclass from typing import List @@ -30,3 +31,17 @@ def render_html(config: AdrTemplateConfig, template_dir_override=None) -> str: template = env.get_template("index.html") return template.render(config=config) + + +def generate_content(adrs: List[Adr], template_dir_override=None, title=None) -> str: + config = AdrTemplateConfig( + project_title=title if title else os.path.basename(os.getcwd()), records=[] + ) + + for index, adr in enumerate(adrs): + adr.index = index + adr.includes_mermaid |= config.include_mermaid + + config.records.append(adr) + + return render_html(config, template_dir_override)