Skip to content

Commit

Permalink
Improve llms.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac-Flath committed Feb 6, 2025
1 parent 830cd80 commit 6544c50
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
21 changes: 20 additions & 1 deletion docs/api_reference/api_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def render_content(c):
else: return c

def create_doc_section(*content, title):
return lambda: Titled(H1(title,cls='mb-10'), *map(render_content, content))
return lambda: Div(Container(*map(render_content, content)))

def string2code_string(code: str) -> tuple: return eval(code), code

Expand All @@ -119,6 +119,7 @@ def _card(i): return Card(H3(f'Card {i}'), P(f'Card {i} content'))
return Slider(*[_card(i) for i in range(10)], items_cls='gap-10', uk_slider='autoplay: true; autoplay-interval: 1000')

docs_sliders = create_doc_section(
H1("Carousel Sliders API Reference"),
"Here is a simple example of a slider:",
fn2code_string(ex_sliders_1),
"Here is a slider with cards:",
Expand Down Expand Up @@ -155,6 +156,7 @@ def ex_links():
A('Classic Link', cls=AT.classic),)

docs_button_link = create_doc_section(
H1("Buttons & Links API Reference"),
Div(id='button'), # for linking to in release post
fn2code_string(ex_buttons),
fn2code_string(ex_links),
Expand All @@ -170,6 +172,7 @@ def ex_theme_switcher():
return Uk_theme_switcher()

docs_theme_headers = create_doc_section(
H1("Theme and Headers API Reference"),
"""
To get headers with a default theme use `hdrs=Theme.<color>.headers()`. For example for the blue theme you would use `hdrs=Theme.blue.headers()`. The theme integrated together different frameworks and allows tailwind, FrankenUI, HighlighJS, and DaisyUI components to work well together.
Expand Down Expand Up @@ -278,6 +281,7 @@ def ex_other():
CodeBlock("#This is a CodeBlock element\n\ndef add(a,b): return a+b"))

docs_typography = create_doc_section(
H1("Typography API Reference"),
P("Ready to go semantic options that cover most of what you need based on the HTML spec"),
fn2code_string(ex_headings),
fn2code_string(ex_semantic_elements),
Expand Down Expand Up @@ -319,6 +323,7 @@ def ex_toasts2():
return Toast("Second Example Toast", alert_cls=AlertT.info)

docs_notifications = create_doc_section(
H1("Alerts & Toasts API Reference"),
H3("Alerts"),
P("The simplest alert is a div wrapped with a span:"),
fn2code_string(ex_alerts1),
Expand Down Expand Up @@ -352,6 +357,7 @@ def ex_containers():


docs_containers = create_doc_section(
H1("Articles, Containers & Sections API Reference"),
ArticleMeta,
ArticleTitle,
Article,
Expand Down Expand Up @@ -429,6 +435,7 @@ def team_member(name, role, location="Remote"):
return Grid(*team, cols_sm=1, cols_md=1, cols_lg=2, cols_xl=3)

docs_cards = create_doc_section(
H1("Cards API Reference"),
H3("Example Usage"),
fn2code_string(ex_card),
(*fn2code_string(ex_card2_wide),'uk-visible@s'),
Expand All @@ -454,6 +461,7 @@ def ex_lists():
return Grid(*lists)

docs_lists = create_doc_section(
H1("Lists API Reference"),
fn2code_string(ex_lists),
ListT,
title="Lists")
Expand Down Expand Up @@ -524,6 +532,7 @@ def ex_form():
DivCentered(Button("Submit Form", cls=ButtonT.primary))))

docs_forms = create_doc_section(
H1("Forms and User Inputs API Reference"),
H3("Example Form"),
P(f"This form was live coded in a 5 minute video ",
A("here",href="https://www.loom.com/share/0916e8a95d524c43a4d100ee85157624?start_and_pause=1",
Expand Down Expand Up @@ -571,7 +580,9 @@ def ex_modal():
footer=ModalCloseButton("Close", cls=ButtonT.primary),id='my-modal'))

docs_modals = create_doc_section(
H1("Modals API Reference"),
H3("Example Modal"),
Subtitle("This is a subtitle"),
fn2code_string(ex_modal),
Modal,
ModalCloseButton,
Expand Down Expand Up @@ -665,6 +676,7 @@ def ex_h_stacked_div():
)

docs_layout = create_doc_section(
H1("Layout (Flex and Grid) API Reference"),
P("This page covers `Grid`s, which are often used for general structure, `Flex` which is often used for layout of components that are not grid based, padding and positioning that can help you make your layout look good, and dividers that can help break up the page", cls=TextPresets.muted_sm),
H2("Grid"),
fn2code_string(ex_grid),
Expand Down Expand Up @@ -714,6 +726,7 @@ def ex_dividerline():
return DividerLine()

docs_dividers = create_doc_section(
H1("Dividers API Reference"),
Divider,
DividerT,
fn2code_string(ex_dividers),
Expand Down Expand Up @@ -815,6 +828,7 @@ def ex_tabs2():
Li(A("Disabled", cls='uk-disabled'))))

docs_navigation = create_doc_section(
H1("Navigation (Nav, NavBar, Tabs, etc.) API Reference"),
H1("Nav, NavBar, DowDownNav, and Tab examples"),
Divider(),
H2("Nav"),
Expand Down Expand Up @@ -873,6 +887,7 @@ def ex_steps3():
cls=(StepsT.vertical, "min-h-[400px]"))

docs_steps = create_doc_section(
H1("Steps API Reference"),
fn2code_string(ex_steps2),
fn2code_string(ex_steps3),
H1("API Docs"),
Expand Down Expand Up @@ -915,6 +930,7 @@ def body_render(k, v):
body_cell_render=body_render)

docs_tables = create_doc_section(
H1("Tables API Reference"),
fn2code_string(ex_tables0),
fn2code_string(ex_tables1),
fn2code_string(ex_tables2),
Expand Down Expand Up @@ -952,6 +968,7 @@ def ex_iconlink():
UkIconLink('chevrons-right', button=True, cls=ButtonT.primary))

docs_icons_images = create_doc_section(
H1("Icons & Images API Reference"),
H1("Avatars"),
fn2code_string(ex_dicebear),
DiceBearAvatar,
Expand Down Expand Up @@ -985,6 +1002,7 @@ def ex_applyclasses():
return apply_classes('<h1>Hello, World!</h1><p>This is a paragraph</p>')

docs_markdown = create_doc_section(
H1("Markdown + automated HTML styling API Reference"),
fn2code_string(ex_markdown),
P("This uses the `apply_classes` function, which can be used to apply classes to html strings"),
apply_classes,
Expand All @@ -1001,6 +1019,7 @@ def ex_loading2():
return Div(*rows, cls='flex flex-col gap-4')

docs_loading = create_doc_section(
H1("Loading IndicatorsAPI Reference"),
fn2code_string(ex_loading1),
fn2code_string(ex_loading2),
Loading,
Expand Down
23 changes: 17 additions & 6 deletions docs/createllms.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
#!/usr/bin/env python3

from fastcore.utils import *
import httpx
import api_reference.api_reference as api_reference
def fname2title(ref_fn_name): return ref_fn_name[5:].replace('_',' | ').title()

def create_llms_txt():
# Get examples
base = "https://monsterui.answer.ai"
examples = [f for f in Path('examples').glob('*.py') if not f.name.startswith('__') and f.name.endswith('.py')]
example_links = [f"[{f.stem.title()}]({base}/{f.name[:-3]}/md)" for f in examples]
example_links = []
for f in examples:
content = httpx.get(f"{base}/{f.stem}/md").text
first_line = content.split('\n')[0].strip('# ').strip('"')
example_links.append(f"[{f.stem.title()}]({base}/{f.name[:-3]}/md): {first_line}")

# Get reference files with their H1 headings
reference_fns = L([o for o in dir(api_reference) if o.startswith('docs_')])
api_links = [f"[{fname2title(f)}]({base}/api_ref/{f}/md)" for f in reference_fns]
api_links = []
for f in reference_fns:
content = httpx.get(f"{base}/api_ref/{f}/md").text
first_heading = content.split('\n')[0].strip('# ')
api_links.append(f"[{fname2title(f)}]({base}/api_ref/{f}/md): {first_heading}")

# Create content
content = [
Expand All @@ -20,15 +31,15 @@ def create_llms_txt():
'''
"## API Reference",
'- [API List](https://raw.githubusercontent.com/AnswerDotAI/MonsterUI/refs/heads/main/docs/apilist.txt)',
'- [API List](https://raw.githubusercontent.com/AnswerDotAI/MonsterUI/refs/heads/main/docs/apilist.txt): Complete API Reference',
"",
"## Examples",
*[f'- {a}' for a in example_links],
"",
"## Optional",
"## Optional",
*[f'- {a}' for a in api_links],
"- [Layout](https://monsterui.answer.ai/tutorial_layout/md)",
"- [Spacing](https://monsterui.answer.ai/tutorial_spacing/md)",
"- [Layout](https://monsterui.answer.ai/tutorial_layout/md): MonsterUI Page Layout Guide",
"- [Spacing](https://monsterui.answer.ai/tutorial_spacing/md): Padding & Margin & Spacing, Oh my! (MonsterUI Spacing Guide)",
]

# Write to file
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/scrollspy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Scrollspy Example"
"MonsterUI Scrollspy Example application"

from fasthtml.common import *
from monsterui.all import *
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MonsterUI
# MonsterUI Getting Started

## Installation

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/Layout.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "09a2b6fa",
"metadata": {},
"source": [
"# Layouts\n",
"# MonterUI Page Layout Guide \n",
"\n",
"This guide will discuss 3 tools for laying out your app pages, Grid, Flexbox, and Columns. This page will discuss the strengths and when to use each individually, and then a section for how to combine them for more complex layouts at the end.\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/Spacing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "ce15239f",
"metadata": {},
"source": [
"# Padding & Margin & Spacing, Oh my!\n",
"# Padding & Margin & Spacing, Oh my! (MonsterUI Spacing Guide)\n",
"\n",
"This guide will cover some essentials about how to properly space apps and what the differences are between:\n",
"\n",
Expand Down

0 comments on commit 6544c50

Please sign in to comment.