|
| 1 | +# -*- coding: utf-8; -*- |
| 2 | +# |
| 3 | +# Licensed to Crate (https://crate.io) under one or more contributor |
| 4 | +# license agreements. See the NOTICE file distributed with this work for |
| 5 | +# additional information regarding copyright ownership. Crate licenses |
| 6 | +# this file to you under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. You may |
| 8 | +# obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | +# License for the specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | +# |
| 18 | +# However, if you have executed another commercial license agreement |
| 19 | +# with Crate these terms will supersede the license and you may use the |
| 20 | +# software solely pursuant to the terms of the relevant commercial agreement. |
| 21 | + |
| 22 | +import typing as t |
| 23 | + |
| 24 | +from sphinx.builders.html import StandaloneHTMLBuilder |
| 25 | + |
| 26 | +from sphinx_design_elements.lib.linktree import LinkTree |
| 27 | + |
| 28 | + |
| 29 | +def make_primary_tree(builder: StandaloneHTMLBuilder, context: t.Dict[str, t.Any]) -> LinkTree: |
| 30 | + project_name = context["project"] |
| 31 | + |
| 32 | + # Create LinkTree component. |
| 33 | + linktree = LinkTree.from_context(builder=builder, context=context) |
| 34 | + linktree.remove_from_title("CrateDB") |
| 35 | + doc = linktree.api.doc |
| 36 | + ref = linktree.api.ref |
| 37 | + link = linktree.api.link |
| 38 | + |
| 39 | + # Add section about project (self). |
| 40 | + project = \ |
| 41 | + linktree \ |
| 42 | + .project(docname=project_name, title=project_name) |
| 43 | + |
| 44 | + # .title("Customized TocTree") \ |
| 45 | + |
| 46 | + # On specific projects, customize the link tree. |
| 47 | + # TODO: Find a way to pull additional navigation hints from project |
| 48 | + # markup itself, in order to get rid of this anomaly. |
| 49 | + if project_name == "CrateDB Docs Theme": |
| 50 | + project.add( |
| 51 | + doc(name="admonitions", label="Admonitions"), |
| 52 | + doc(name="codesnippets", label="Code snippets"), |
| 53 | + doc(name="myst/mermaid", label="Mermaid diagrams, written in Markdown"), |
| 54 | + ) |
| 55 | + |
| 56 | + # Add project toctree. |
| 57 | + project.toctree() |
| 58 | + |
| 59 | + # Add section with links to intersphinx targets. |
| 60 | + |
| 61 | + # CrateDB Database. |
| 62 | + linktree \ |
| 63 | + .title("CrateDB Database") \ |
| 64 | + .add( |
| 65 | + ref(target="crate-reference:index", label="CrateDB Reference"), |
| 66 | + ref(target="crate-tutorials:index", label="Install CrateDB"), |
| 67 | + ref(target="crate-howtos:index", label="Getting started"), |
| 68 | + ) |
| 69 | + |
| 70 | + # CrateDB Cloud. |
| 71 | + linktree \ |
| 72 | + .title("CrateDB Cloud") \ |
| 73 | + .add( |
| 74 | + ref("cloud-reference:index"), |
| 75 | + ref("cloud-tutorials:index"), |
| 76 | + ref("cloud-howtos:index"), |
| 77 | + ref("cloud-cli:index"), |
| 78 | + ) |
| 79 | + |
| 80 | + # CrateDB clients. |
| 81 | + linktree \ |
| 82 | + .title("Clients") \ |
| 83 | + .add( |
| 84 | + ref("crate-admin-ui:index"), |
| 85 | + ref("crate-crash:index"), |
| 86 | + ref("crate-clients-tools:index"), |
| 87 | + ref("crate-jdbc:index"), |
| 88 | + ref("crate-npgsql:index"), |
| 89 | + ref("crate-dbal:index"), |
| 90 | + ref("crate-pdo:index"), |
| 91 | + ref("crate-python:index"), |
| 92 | + ) |
| 93 | + |
| 94 | + # Other links. |
| 95 | + linktree \ |
| 96 | + .title("Miscellaneous") \ |
| 97 | + .add( |
| 98 | + link(uri="https://crate.io/support/", label="Support"), |
| 99 | + link(uri="https://community.crate.io/", label="Community"), |
| 100 | + link(uri="https://community.crate.io/t/overview-of-cratedb-integration-tutorials/1015", label="Integration tutorials"), |
| 101 | + link(uri="https://github.com/crate/cratedb-examples", label="Stacks and examples"), |
| 102 | + link(uri="https://github.com/crate/crate-sample-apps", label="Sample applications"), |
| 103 | + ref("sql-99:index"), |
| 104 | + # ref("crate-docs-theme:index"), |
| 105 | + # ref("crate-docs:index"), |
| 106 | + ) |
| 107 | + |
| 108 | + return linktree |
0 commit comments