|
28 | 28 | from __future__ import annotations
|
29 | 29 |
|
30 | 30 | from pathlib import Path
|
31 |
| -from typing import List |
32 | 31 |
|
33 |
| -from pulp_docs.constants import Names |
34 | 32 | from pulp_docs.repository import Repos
|
35 | 33 | from pulp_docs.utils.aggregation import AgregationUtils
|
36 | 34 |
|
@@ -58,82 +56,32 @@ def grouped_by_persona(tmpdir: Path, repos: Repos):
|
58 | 56 | {content-type}
|
59 | 57 | """
|
60 | 58 | f = AgregationUtils(tmpdir, repos)
|
61 |
| - SECTION_HOST = "pulp-docs" |
62 | 59 |
|
63 | 60 | # Manual section for each persona
|
64 | 61 | TEMPLATE_STR = "{repo}/docs/{persona}/{content}"
|
65 | 62 | manual_nav = {
|
66 | 63 | "user": [
|
67 |
| - {"Overview": f"{SECTION_HOST}/docs/sections/user/index.md"}, |
68 |
| - *f.repo_grouping(TEMPLATE_STR, personas=["user", "admin"]) |
| 64 | + {"Overview": "user/index.md"}, |
| 65 | + *f.repo_grouping(TEMPLATE_STR, personas=["user", "admin"]), |
69 | 66 | ],
|
70 | 67 | "dev": [
|
71 |
| - {"Overview": f"{SECTION_HOST}/docs/sections/dev/index.md"}, |
72 |
| - *f.repo_grouping(TEMPLATE_STR, personas=["dev"]) |
| 68 | + {"Overview": "dev/index.md"}, |
| 69 | + *f.repo_grouping(TEMPLATE_STR, personas=["dev"]), |
73 | 70 | ],
|
74 | 71 | }
|
75 | 72 |
|
76 | 73 | # Custom help section
|
77 | 74 | help_section = [
|
78 |
| - {"Overview": f"{SECTION_HOST}/docs/sections/help/index.md"}, |
79 |
| - {"Community": f"{SECTION_HOST}/docs/sections/help/community/"}, |
80 |
| - {"More": f"{SECTION_HOST}/docs/sections/help/more/"}, |
| 75 | + {"Overview": "help/index.md"}, |
| 76 | + {"Community": "help/community/"}, |
| 77 | + {"More": "help/more/"}, |
81 | 78 | ]
|
82 | 79 |
|
83 |
| - # Main Section |
84 |
| - # pulpcore_nav = manual_nav["user"][1]["Core"][0] |
85 |
| - # pulpcore_nav = create_repo_toc_index(pulpcore_nav) |
86 |
| - # print(pulpcore_nav) |
87 |
| - # manual_nav["user"][1]["Core"][0] = pulpcore_nav |
88 |
| - |
89 | 80 | navigation = [
|
90 | 81 | {"Home": "index.md"},
|
91 | 82 | {"User Manual": manual_nav["user"]},
|
92 | 83 | {"Developer Manual": manual_nav["dev"]},
|
93 |
| - {"Blog": ["pulp-docs/docs/sections/blog/index.md"]}, |
| 84 | + {"Blog": ["blog/index.md"]}, |
94 | 85 | {"Help": help_section},
|
95 | 86 | ]
|
96 | 87 | return navigation
|
97 |
| - |
98 |
| - |
99 |
| -def create_repo_toc_index(repo_nav: List[dict]): |
100 |
| - """ |
101 |
| - TODO: maybe try to leverage site-map |
102 |
| -
|
103 |
| - Create a toc with the format: {tuple-path: file-path} |
104 |
| -
|
105 |
| - Sample input: |
106 |
| - {'Pulp Core': [{'User': [{'Tutorials': 'pulpcore/docs/user/tutorials/'}, |
107 |
| - {'How-to Guides': 'pulpcore/docs/user/guides/'}, |
108 |
| - {'Learn More': 'pulpcore/docs/user/learn/'}]}, |
109 |
| - {'Admin': [{'How-to Guides': 'pulpcore/docs/admin/guides/'}, |
110 |
| - {'Learn More': 'pulpcore/docs/admin/learn/'}]}, |
111 |
| - {'REST API': 'pulpcore/restapi.md'}, |
112 |
| - {'Changelog': 'pulpcore/changes.md'}]} |
113 |
| - """ |
114 |
| - |
115 |
| - def is_nav(item): |
116 |
| - return isinstance(item, list) |
117 |
| - |
118 |
| - # {dir-path: page-str} |
119 |
| - toc = {} |
120 |
| - path = [] |
121 |
| - |
122 |
| - def recursive_add(nav): |
123 |
| - for name, item in nav.items(): |
124 |
| - path.append(name) |
125 |
| - if isinstance(item, list): |
126 |
| - for entry in item: |
127 |
| - recursive_add(entry) |
128 |
| - path.pop() |
129 |
| - elif isinstance(item, dict): |
130 |
| - item_name, entry = item.items() |
131 |
| - path.append(item_name) |
132 |
| - recursive_add(entry) |
133 |
| - toc[tuple(path)] = None |
134 |
| - path.pop() |
135 |
| - else: |
136 |
| - toc[tuple(path)] = item |
137 |
| - |
138 |
| - recursive_add(repo_nav) |
139 |
| - return toc |
0 commit comments