Skip to content

Commit

Permalink
Schema Library: Load minimal README (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
FragmentedPacket authored Jan 26, 2025
1 parent d935a24 commit 85ba9fc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pages/schema_library.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import os
import re
from datetime import datetime
from enum import Enum
from itertools import chain
Expand Down Expand Up @@ -62,6 +63,9 @@ async def init_schema_extension_state(schema_extension: str) -> None:
st.session_state.extensions_states[schema_extension] = SchemaState.NOT_LOADED

schema_kinds = st.session_state.schema_kinds.get(schema_extension)
# TODO: This accounts for qinq that only has a schema extension and no schema kinds. We need to account for node extensions here as well.
if not schema_kinds:
return
existing_schemas = await get_schema_async(refresh=True)
if schema_kinds.issubset(existing_schemas):
st.session_state.extensions_states[schema_extension] = SchemaState.LOADED
Expand Down Expand Up @@ -129,7 +133,20 @@ def on_click_schema_load(schema_extension: str):

def render_schema_extension_content(schema_path: Path, schema_name: str, schema_files: list[SchemaFile]) -> None:
# Render description for the extension
st.write(check_and_open_readme(schema_path))
readme = check_and_open_readme(schema_path)
# Regex pattern to capture everything before and after ## Overview
pattern = re.compile(r"([\s\S]*?)(^## Overview[\s\S]*)", re.MULTILINE)
# Find matches
match = pattern.match(readme)
if match:
before_overview = match.group(1)
st.markdown(before_overview)
overview_and_below = match.group(2)
with st.expander("More details..."):
st.markdown(overview_and_below)
else:
# This is encountered if there is no "## Overview" in the README (qinq README as an example)
st.markdown(readme)

# Prepare vars for the button
is_button_disabled: bool = False
Expand Down

0 comments on commit 85ba9fc

Please # to comment.