generated from silverbulletmd/silverbullet-plug-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from justyns/mkdocs
Switch documentation to a combination of silverbullet-pub and mkdocs
- Loading branch information
Showing
21 changed files
with
234 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ docs/Library/Core | |
!docs/_plug | ||
SECRETS.md | ||
cov_profile | ||
test?space* | ||
test?space* | ||
site/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
tags: template | ||
--- | ||
|
||
* **{{ref}}** {{#if aiprompt}}{{aiprompt.description}}{{else}}{{description}}{{/if}} | ||
{{#if aiprompt.usage}} | ||
* **Usage:** {{aiprompt.usage}} | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import logging | ||
import re | ||
import mkdocs.plugins | ||
import os.path | ||
|
||
log = logging.getLogger('mkdocs') | ||
|
||
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__))) | ||
|
||
def find_target_file(root_dir, link): | ||
# Implement the logic to find the target file | ||
# This is a placeholder implementation | ||
potential_path = os.path.join(root_dir, f"{link}.md") | ||
return potential_path if os.path.exists(potential_path) else None | ||
|
||
def replace_wiki_link(match, root_dir, page): | ||
# Wiki links in silverbullet are always relative from the root space directory | ||
link = match.group(1).strip() | ||
alias = match.group(2).strip() if len(match.groups()) > 1 and match.group(2) else os.path.basename(link) | ||
target_path = find_target_file(root_dir, link) | ||
log.info(f"target_path: {target_path}") | ||
log.info(f"page.file.abs_src_path: {page.file.abs_src_path}") | ||
if target_path: | ||
relative_path = os.path.relpath(target_path, os.path.dirname(os.path.dirname(page.file.abs_src_path))) | ||
log.info(f"wiki link: {link} -> {relative_path}") | ||
return f'[{alias}]({relative_path})' | ||
else: | ||
log.warning(f"Target file not found for wiki link: {link}") | ||
return f'[{alias}]({link}.md)' | ||
|
||
def convert_admonitions(markdown): | ||
# Convert blockquotes with bold headers to MkDocs-style admonitions | ||
# Matches lines starting with "> **Header**:" and captures the header and content | ||
return re.sub(r'^> \*\*([\w\s]+)\*\*:\s*(.*(?:\n(?!>).*)*)', r'!!! \1\n\n \2', markdown, flags=re.MULTILINE) | ||
|
||
def process_links(markdown, root_dir, page): | ||
# Convert wiki-style links [[Page]] or [[Page|Alias]] to Markdown links | ||
# Captures the page name and optional alias, then calls replace_wiki_link function | ||
return re.sub(r'\[\[([^|\]]+)(?:\|([^\]]+))?\]\]', lambda m: replace_wiki_link(m, root_dir, page), markdown) | ||
|
||
@mkdocs.plugins.event_priority(-50) | ||
def on_page_markdown(markdown, page, **kwargs): | ||
markdown = process_links(markdown, root_dir, page) | ||
markdown = convert_admonitions(markdown) | ||
return markdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
site_name: Silverbullet AI Plug | ||
repo_url: https://github.com/justyns/silverbullet-ai | ||
edit_uri: edit/main/docs/ | ||
docs_dir: docs/_public | ||
theme: | ||
name: material | ||
color_mode: auto | ||
user_color_mode_toggle: true | ||
palette: | ||
# Palette toggle for light mode | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: default | ||
toggle: | ||
icon: material/brightness-7 | ||
name: Switch to dark mode | ||
# Palette toggle for dark mode | ||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
toggle: | ||
icon: material/brightness-4 | ||
name: Switch to light mode | ||
features: | ||
- navigation.footer | ||
- navigation.path | ||
- navigation.indexes | ||
- content.action.edit | ||
- content.code.copy | ||
- content.code.annotate | ||
- search.suggest | ||
- search.highlight | ||
- search.share | ||
|
||
markdown_extensions: | ||
- pymdownx.highlight: | ||
anchor_linenums: true | ||
line_spans: __span | ||
pygments_lang_class: true | ||
- pymdownx.inlinehilite | ||
- pymdownx.snippets | ||
- pymdownx.superfences | ||
- pymdownx.keys | ||
- admonition | ||
- pymdownx.details | ||
- footnotes | ||
# - wikilinks | ||
# - def_list | ||
- mdx_truly_sane_lists | ||
|
||
extra: | ||
social: | ||
- icon: fontawesome/brands/github | ||
link: https://github.com/justyns/silverbullet-ai | ||
|
||
plugins: | ||
- include_dir_to_nav | ||
- search | ||
# TODO: Doesn't really work with pub since it creates new files | ||
# - git-revision-date-localized: | ||
# enable_creation_date: true | ||
# - optimize | ||
|
||
hooks: | ||
- docs/mkdocs-sb.py | ||
|
||
watch: | ||
- docs/_public | ||
- docs/mkdocs-sb.py | ||
- mkdocs.yml | ||
|
||
exclude_docs: | | ||
SETTINGS.md | ||
PLUGS.md | ||
SECRETS.md | ||
template/ | ||
Library/ | ||
Features.md | ||
Commands.md | ||
nav: | ||
- Home: index.md | ||
- Quick Start.md | ||
- Installation.md | ||
- Configuration: | ||
- Configuration.md | ||
- Configuration | ||
- AI Core Library.md | ||
- Templated Prompts.md | ||
- Commands: | ||
- Commands | ||
- Providers: | ||
- Providers | ||
- Changelog.md | ||
- Development.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!env bash | ||
|
||
# Publish using the pub plugin to render code blocks/queries/etc | ||
SB_DB_BACKEND=memory deno run --unstable-kv --unstable-worker-options -A https://edge.silverbullet.md/silverbullet.js plug:run docs/ pub.publishAll && cp -v docs/style.css docs/_public/ | ||
|
||
# Delete html files | ||
find docs/_public -type f -name \*.html -delete | ||
find docs/_public -type d -empty -delete | ||
|
||
# Delete extra sb-specific files | ||
|
||
rm -fv \ | ||
docs/_public/SETTINGS.md \ | ||
docs/_public/PLUGS.md \ | ||
docs/_public/*.css |