From 756e833a5b0eed6430e3ab8e16b20b53b6f0eef1 Mon Sep 17 00:00:00 2001
From: Romain Deville <code@romaindeville.fr>
Date: Thu, 13 May 2021 10:52:49 +0200
Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20plugins.py=20in=20docu?=
 =?UTF-8?q?mentation=20and=20tpl.yaml?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 docs/_data/plugins.py                | 26 ++++++++++++++------------
 docs/_data/template/repo.tpl.yaml    | 10 +++++++---
 docs/_data/template/subrepo.tpl.yaml | 10 ++++++++++
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/docs/_data/plugins.py b/docs/_data/plugins.py
index cbac051..d47f6eb 100644
--- a/docs/_data/plugins.py
+++ b/docs/_data/plugins.py
@@ -153,6 +153,10 @@ def add_external_to_nav(
                         repo_parent,
                         nav_parent[1:],
                     )
+    elif repo_dict["online_url"].startswith('/'):
+        nav.append({
+            repo_dict["nav_entry"]: repo_dict["online_url"].replace('/','../',1)
+        })
     else:
         nav.append({repo_dict["nav_entry"]: repo_dict["online_url"]})
 
@@ -833,10 +837,8 @@ def update_version(env: dict) -> None:
             if last_major >= 0:
                 mike_version.append(
                     {
-                        "version": "{}.{}".format(last_major, last_minor),
-                        "title": "{}.{}.{}".format(
-                            last_major, last_minor, last_patch
-                        ),
+                        "version": f"{last_major}.{last_minor}",
+                        "title": f"{last_major}.{last_minor}.{last_patch}",
                         "aliases": [],
                     }
                 )
@@ -846,10 +848,8 @@ def update_version(env: dict) -> None:
             if last_minor >= 0:
                 mike_version.append(
                     {
-                        "version": "{}.{}".format(last_major, last_minor),
-                        "title": "{}.{}.{}".format(
-                            last_major, last_minor, last_patch
-                        ),
+                        "version": f"{last_major}.{last_minor}",
+                        "title": f"{last_major}.{last_minor}.{last_patch}",
                         "aliases": [],
                     }
                 )
@@ -859,8 +859,8 @@ def update_version(env: dict) -> None:
             last_patch = patch
     mike_version.append(
         {
-            "version": "{}.{}".format(last_major, last_minor),
-            "title": "{}.{}.{}".format(last_major, last_minor, last_patch),
+            "version": f"{last_major}.{last_minor}",
+            "title": f"{last_major}.{last_minor}.{last_patch}",
             "aliases": ["latest"],
         }
     )
@@ -914,9 +914,11 @@ def define_env(env: dict) -> None:
             var: Key in env.variables to return.
 
         Returns:
-            The value of `env.variables[var]`.
+            The value of `env.variables[var]` if it exists, else return None.
         """
-        return env.variables[var]
+        if var in env.variables:
+            return env.variables[var]
+        return None
 
     @env.macro
     # pylint: disable=W0612
diff --git a/docs/_data/template/repo.tpl.yaml b/docs/_data/template/repo.tpl.yaml
index 8fb19b0..900e5c8 100644
--- a/docs/_data/template/repo.tpl.yaml
+++ b/docs/_data/template/repo.tpl.yaml
@@ -1,3 +1,4 @@
+
 ### BEGIN MKDOCS TEMPLATE ###
 ### WARNING, DO NOT UPDATE CONTENT BETWEEN MKDOCS TEMPLATE TAG !###
 ### Modified content will be overwritten when updating.###
@@ -29,11 +30,13 @@ repo_name:
 
   # (OPTIONAL) Path, relative to `docs_dir` mkdocs config, to the logo of the
   # repo. If not specified, path will automatically be set to
-  # `assets/img/meta/reop_name_logo.png`
-  #logo: "assets/img/meta/repo_template_logo.png"
+  # `assets/img/meta/repo_name_logo.png`
+  #logo: "assets/img/meta/repo_name_logo.png"
   # Description of the repo, will be used to setup the mkdocs description.
   desc: >-
-    Repo description with markdown support
+    An explicit description to explain what my repo do. Can be a multiline
+    description with **markdown** support such as
+    [link](https://url.domain.tld) and more.
 
   # (OPTIONAL) If you plan to use `mkdocstring` plugins to render python
   # source code, you will need to provide the path where your source files
@@ -47,3 +50,4 @@ repo_name:
     - name: "Firstname Lastname"
       mail: "mail@domain.tld"
 ### END MKDOCS TEMPLATE ###
+
diff --git a/docs/_data/template/subrepo.tpl.yaml b/docs/_data/template/subrepo.tpl.yaml
index 07ca0f4..bd0ff06 100644
--- a/docs/_data/template/subrepo.tpl.yaml
+++ b/docs/_data/template/subrepo.tpl.yaml
@@ -1,3 +1,4 @@
+
 ### BEGIN MKDOCS TEMPLATE ###
 ### WARNING, DO NOT UPDATE CONTENT BETWEEN MKDOCS TEMPLATE TAG !###
 ### Modified content will be overwritten when updating.###
@@ -25,6 +26,10 @@ subrepo:
   #     - name: subrepo_1
   #       # SSH or HTTP link to the online subrepo_1
   #       git_url: git@domain.tld:namesapce/subrepo_1
+  #       # Key `subpath` is a str pointing to the path in the subrepo where
+  #       # there is a file `mkdocs.yaml` and folder `docs` if not the root
+  #       # of the subrepo
+  #       subpath: sub/dir/
   #   # List of subdirectory from `dir_name` which are repos with
   #   # mkdocs documentation which will be included in the documentation.
   #   external:
@@ -34,6 +39,10 @@ subrepo:
   #     - name: subrepo_2
   #       # SSH or HTTP link to the online subrepo_2
   #       git_url: git@domain.tld:namesapce/subrepo_2
+  #       # Key `subpath` is a str pointing to the path in the subrepo where
+  #       # there is a file `mkdocs.yaml` and folder `docs` if not the root
+  #       # of the subrepo
+  #       subpath: sub/dir/
   #   # Another sub dir_name which also old subrepos
   #   subdir_name:
   #     nav_entry: "Sub Nav Entry"
@@ -75,3 +84,4 @@ subrepo:
   #     - Mkdocs Template: /my_program/mkdocs_template/
   # ```
 ### END MKDOCS TEMPLATE ###
+
-- 
GitLab