mkdocs-simple-plugin 3.2.4__tar.gz → 4.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,3 +9,4 @@ dist/
9
9
  venv/
10
10
  docs/
11
11
  artifact.tar
12
+ .env
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-simple-plugin
3
- Version: 3.2.4
3
+ Version: 4.0.1
4
4
  Summary: Plugin for adding simple wiki site creation from markdown files interspersed within your code with MkDocs.
5
5
  Project-URL: Documentation, http://www.althack.dev/mkdocs-simple-plugin
6
6
  Project-URL: Homepage, http://www.althack.dev/mkdocs-simple-plugin
@@ -29,7 +29,7 @@ Description-Content-Type: text/markdown
29
29
  ![mkdocs-simple-plugin](https://github.com/athackst/mkdocs-simple-plugin/raw/main/media/mkdocs-simple-plugin.png)
30
30
 
31
31
  [![Test](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/test.yml)
32
- [![Docs](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/publish_docs.yml/badge.svg?branch=main)](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/publish_docs.yml)
32
+ [![Site](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/site.yml/badge.svg)](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/site.yml)
33
33
  [![Docker](https://img.shields.io/docker/pulls/althack/mkdocs-simple-plugin)](https://hub.docker.com/r/althack/mkdocs-simple-plugin)
34
34
  [![pypi](https://img.shields.io/pypi/dm/mkdocs-simple-plugin?label=pypi%20downloads&color=blue)](https://pypi.org/project/mkdocs-simple-plugin/)
35
35
  [![Github Action](https://img.shields.io/badge/github%20action-download-blue)](https://github.com/marketplace/actions/mkdocs-simple-action)
@@ -1,7 +1,7 @@
1
1
  ![mkdocs-simple-plugin](https://github.com/athackst/mkdocs-simple-plugin/raw/main/media/mkdocs-simple-plugin.png)
2
2
 
3
3
  [![Test](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/test.yml)
4
- [![Docs](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/publish_docs.yml/badge.svg?branch=main)](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/publish_docs.yml)
4
+ [![Site](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/site.yml/badge.svg)](https://github.com/athackst/mkdocs-simple-plugin/actions/workflows/site.yml)
5
5
  [![Docker](https://img.shields.io/docker/pulls/althack/mkdocs-simple-plugin)](https://hub.docker.com/r/althack/mkdocs-simple-plugin)
6
6
  [![pypi](https://img.shields.io/pypi/dm/mkdocs-simple-plugin?label=pypi%20downloads&color=blue)](https://pypi.org/project/mkdocs-simple-plugin/)
7
7
  [![Github Action](https://img.shields.io/badge/github%20action-download-blue)](https://github.com/marketplace/actions/mkdocs-simple-action)
@@ -53,24 +53,48 @@ def default_config():
53
53
  # Set the default edit uri to empty since doc files are built from source
54
54
  # and may not exist.
55
55
  config['edit_uri'] = ''
56
+ return config
57
+
58
+
59
+ def apply_environment_config(config, existing_config=None):
60
+ """Set config values from non-empty environment inputs."""
61
+ existing_config = existing_config or {}
56
62
 
57
63
  def maybe_set_string(name):
64
+ env_variable = "DEFAULT_" + name.upper()
65
+ config_variable = name.lower()
66
+ config_exists = config_variable in existing_config
67
+ if os.environ.get(env_variable) and not config_exists:
68
+ config[config_variable] = os.environ[env_variable]
69
+
70
+ def maybe_set_dict(name, key):
71
+ env_variable = "DEFAULT_" + name.upper()
72
+ config_variable = name.lower()
73
+ config_exists = config_variable in existing_config
74
+ if os.environ.get(env_variable) and not config_exists:
75
+ config[config_variable] = {key: os.environ[env_variable]}
76
+
77
+ def set_string(name):
58
78
  env_variable = "INPUT_" + name.upper()
59
79
  config_variable = name.lower()
60
80
  if os.environ.get(env_variable):
61
81
  config[config_variable] = os.environ[env_variable]
62
82
 
63
- def maybe_set_dict(name, key):
83
+ def set_dict(name, key):
64
84
  env_variable = "INPUT_" + name.upper()
65
85
  config_variable = name.lower()
66
86
  if os.environ.get(env_variable):
67
87
  config[config_variable] = {key: os.environ[env_variable]}
68
- # Set the config variables via environment if exist
88
+
69
89
  maybe_set_string("site_name")
70
90
  maybe_set_string("site_url")
71
91
  maybe_set_string("repo_url")
72
92
  maybe_set_dict("theme", "name")
73
- return config
93
+
94
+ set_string("site_name")
95
+ set_string("site_url")
96
+ set_string("repo_url")
97
+ set_dict("theme", "name")
74
98
 
75
99
 
76
100
  class MkdocsConfigDumper(yaml.Dumper):
@@ -100,9 +124,11 @@ def write_config(config_file, config):
100
124
  def setup_config(config_file="mkdocs.yml"):
101
125
  """Create the mkdocs.yml file with defaults for params that don't exist."""
102
126
  config = default_config()
127
+ local_config = {}
103
128
  if not os.path.exists(config_file):
104
129
  # If config file doesn't exit, create a simple one, guess the site name
105
130
  # from the folder name.
131
+ apply_environment_config(config)
106
132
  write_config(config_file, config)
107
133
  # Open the config file to verify settings.
108
134
  with open(config_file, 'r', encoding="utf-8") as stream:
@@ -112,6 +138,7 @@ def setup_config(config_file="mkdocs.yml"):
112
138
  # Overwrite default config values with local mkdocs.yml
113
139
  config.update(local_config)
114
140
  print(config)
141
+ apply_environment_config(config, local_config)
115
142
  if not os.path.exists(config["docs_dir"]):
116
143
  # Ensure docs directory exists.
117
144
  print("making docs_dir %s", config["docs_dir"])