|
22 | 22 | import posixpath |
23 | 23 |
|
24 | 24 | from mergedeep import merge |
25 | | -from mkdocs.config.defaults import MkDocsConfig |
| 25 | +from material.plugins.projects.structure import Project |
26 | 26 |
|
27 | 27 | # ----------------------------------------------------------------------------- |
28 | 28 | # Functions |
29 | 29 | # ----------------------------------------------------------------------------- |
30 | 30 |
|
31 | 31 | # Transform project configuration |
32 | | -def transform(project: MkDocsConfig, config: MkDocsConfig): |
33 | | - base = os.path.dirname(project.config_file_path) |
| 32 | +def transform(project: Project, root: Project): |
| 33 | + config = root.config |
| 34 | + |
| 35 | + base = os.path.dirname(project.config.config_file_path) |
34 | 36 | name = os.path.basename(base) |
35 | 37 |
|
36 | 38 | # Determine path of examples relative to root |
37 | 39 | root = os.path.dirname(config.config_file_path) |
38 | 40 | path = os.path.relpath(base, root) |
39 | 41 |
|
40 | 42 | # Inherit settings for repository |
41 | | - project.repo_name = config.repo_name |
42 | | - project.repo_url = f"{config.repo_url}/tree/master/{path}" |
| 43 | + project.config.repo_name = config.repo_name |
| 44 | + project.config.repo_url = f"{config.repo_url}/tree/master/{path}" |
43 | 45 |
|
44 | 46 | # Inherit settings for site URL and edit URI |
45 | | - project.site_url = posixpath.join(config.site_url, name, "") |
46 | | - project.edit_uri = f"edit/master/examples/{name}/docs/" |
47 | | - |
48 | | - # Inherit settings for copyright |
49 | | - project.copyright = config.copyright |
| 47 | + project.config.site_url = posixpath.join(config.site_url, name, "") |
| 48 | + project.config.edit_uri = f"edit/master/examples/{name}/docs/" |
50 | 49 |
|
51 | 50 | # Inherit settings for theme |
52 | | - if "features" in project.theme: |
53 | | - project.theme["features"].extend(config.theme["features"]) |
| 51 | + if "features" in project.config.theme: |
| 52 | + project.config.theme["features"].extend(config.theme["features"]) |
54 | 53 | else: |
55 | | - project.theme["features"] = config.theme["features"] |
| 54 | + project.config.theme["features"] = config.theme["features"] |
56 | 55 |
|
57 | | - if "icon" in project.theme: |
58 | | - merge(project.theme["icon"], config.theme["icon"]) |
| 56 | + if "icon" in project.config.theme: |
| 57 | + merge(project.config.theme["icon"], config.theme["icon"]) |
59 | 58 | else: |
60 | | - project.theme["icon"] = config.theme["icon"] |
| 59 | + project.config.theme["icon"] = config.theme["icon"] |
0 commit comments