Skip to content

Commit

Permalink
refactor(init): Move parse_adr_files up into main
Browse files Browse the repository at this point in the history
Now `generate_content` can be put into `render`
  • Loading branch information
mrwilson committed Oct 8, 2023
1 parent 847250d commit 63fb0f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions adr_viewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
from adr_viewer.server import run_server


def generate_content(path, template_dir_override=None, title=None) -> str:
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=[]
)

adrs: List[Adr] = parse_adr_files("%s/*.md" % path)

for index, adr in enumerate(adrs):
adr.index = index
adr.includes_mermaid |= config.include_mermaid
Expand All @@ -34,7 +32,9 @@ def generate_content(path, template_dir_override=None, title=None) -> str:
@option('--template-dir', default=None, help='Template directory.', show_default=True)
# fmt: on
def main(adr_path, output, title, serve, port, template_dir) -> None:
content = generate_content(adr_path, template_dir, title)
adrs: List[Adr] = parse_adr_files("%s/*.md" % adr_path)

content = generate_content(adrs, template_dir, title)

if serve:
run_server(content, port)
Expand Down

0 comments on commit 63fb0f6

Please sign in to comment.