fixed book links

This commit is contained in:
Maccesch 2023-06-05 00:51:04 +01:00
parent 5f06393eba
commit 81c4e591c0
2 changed files with 52 additions and 9 deletions

39
.github/workflows/book.yml vendored Normal file
View file

@ -0,0 +1,39 @@
on:
workflow_dispatch:
name: Book
permissions:
contents: read
pages: write
id-token: write
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Install mdbook I
uses: taiki-e/install-action@v2
with:
tool: cargo-binstall,mdbook
- name: Install mdbook II
run: |
cargo binstall -y mdbook-cmdrun
cargo binstall -y trunk
rustup target add wasm32-unknown-unknown
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Build mdbook
run: |
cd docs/book
mdbook build
python3 post_build.py
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./docs/book/book
- name: Deploy book to github pages
id: deployment
uses: actions/deploy-pages@v2

View file

@ -84,13 +84,15 @@ def add_source_paragraph(name, module):
print("\n## Source\n") print("\n## Source\n")
if module is not None: if module is not None:
module = f"/{module}" mod = f"/{module}"
else:
mod = ""
source_url = f"https://github.com/Synphonyte/leptos-use/blob/main/src{module}/{name}.rs" source_url = f"https://github.com/Synphonyte/leptos-use/blob/main/src{mod}/{name}.rs"
demo_url = f"https://github.com/Synphonyte/leptos-use/tree/main/examples/{name}" demo_url = f"https://github.com/Synphonyte/leptos-use/tree/main/examples/{name}"
docs_url = f"https://docs.rs/leptos-use/latest/leptos_use{module}/fn.{name}.html" docs_url = f"https://docs.rs/leptos-use/latest/leptos_use{mod}/fn.{name}.html"
demo_link = " • <a href=\"{demo_url}\" target=\"_blank\">Demo</a>" if os.path.isdir( demo_link = f" • <a href=\"{demo_url}\" target=\"_blank\">Demo</a>" if os.path.isdir(
os.path.join("..", "..", "..", "..", "examples", name)) else "" os.path.join("..", "..", "..", "..", "examples", name)) else ""
print( print(
@ -113,10 +115,12 @@ def process_line(line, name, module):
</div>''' </div>'''
else: else:
if module is not None: if module is not None:
module = f"/{module}" mod = f"/{module}"
else:
mod = ""
result = re.sub(internal_doc_link_pattern, result = re.sub(internal_doc_link_pattern,
rf"[`\1`](https://docs.rs/leptos-use/latest/leptos_use{module}/fn.\1.html)", rf"[`\1`](https://docs.rs/leptos-use/latest/leptos_use{mod}/fn.\1.html)",
line) line)
return result return result
@ -141,11 +145,11 @@ def append_type(line, ty, types, module=None):
ident = m.group(0) ident = m.group(0)
if module is not None: if module is not None:
module = f"/{module}" mod = f"/{module}"
else: else:
module = "" mod = ""
types.append(f"- [`{ty} {ident}`](https://docs.rs/leptos-use/latest/leptos_use{module}/{ty}.{ident}.html)") types.append(f"- [`{ty} {ident}`](https://docs.rs/leptos-use/latest/leptos_use{mod}/{ty}.{ident}.html)")
if __name__ == '__main__': if __name__ == '__main__':