From 81c4e591c0b4798912d603e8760b7c295f443a8c Mon Sep 17 00:00:00 2001 From: Maccesch Date: Mon, 5 Jun 2023 00:51:04 +0100 Subject: [PATCH] fixed book links --- .github/workflows/book.yml | 39 ++++++++++++++++++++++++++++ docs/book/src/extract_doc_comment.py | 22 +++++++++------- 2 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/book.yml diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml new file mode 100644 index 0000000..0d91fa1 --- /dev/null +++ b/.github/workflows/book.yml @@ -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 diff --git a/docs/book/src/extract_doc_comment.py b/docs/book/src/extract_doc_comment.py index 78d2913..762b32f 100644 --- a/docs/book/src/extract_doc_comment.py +++ b/docs/book/src/extract_doc_comment.py @@ -84,13 +84,15 @@ def add_source_paragraph(name, module): print("\n## Source\n") 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}" - 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 = " • Demo" if os.path.isdir( + demo_link = f" • Demo" if os.path.isdir( os.path.join("..", "..", "..", "..", "examples", name)) else "" print( @@ -113,10 +115,12 @@ def process_line(line, name, module): ''' else: if module is not None: - module = f"/{module}" + mod = f"/{module}" + else: + mod = "" 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) return result @@ -141,11 +145,11 @@ def append_type(line, ty, types, module=None): ident = m.group(0) if module is not None: - module = f"/{module}" + mod = f"/{module}" 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__':