FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DevOps Division Guidebook
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Information Services
DevOps
General Documentation
DevOps Division Guidebook
Commits
bcb05387
Commit
bcb05387
authored
1 month ago
by
Nick Brown
Browse files
Options
Downloads
Patches
Plain Diff
feat: Added macros/utils define_env and site_url macro definition
parent
610ff1a8
No related branches found
No related tags found
1 merge request
!453
feat: Knowledge base enhancements (diataxis)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
macros/__init__.py
+2
-1
2 additions, 1 deletion
macros/__init__.py
macros/utils.py
+16
-0
16 additions, 0 deletions
macros/utils.py
with
18 additions
and
1 deletion
macros/__init__.py
+
2
−
1
View file @
bcb05387
...
...
@@ -11,7 +11,7 @@ import re
import
yaml
from
mkdocs_macros.plugin
import
MacrosPlugin
from
.
import
(
diagram
,
gitlab
,
services
,
table
)
from
.
import
(
diagram
,
gitlab
,
services
,
table
,
utils
)
from
.constants
import
TEMPLATE_VARIABLES
def
define_env
(
env
:
MacrosPlugin
):
...
...
@@ -27,3 +27,4 @@ def define_env(env: MacrosPlugin):
gitlab
.
define_env
(
env
)
services
.
define_env
(
env
)
table
.
define_env
(
env
)
utils
.
define_env
(
env
)
This diff is collapsed.
Click to expand it.
macros/utils.py
+
16
−
0
View file @
bcb05387
...
...
@@ -3,6 +3,8 @@
from
mkdocs_macros.plugin
import
MacrosPlugin
from
urllib.parse
import
urljoin
# Utilities:
def
environment
(
env
:
MacrosPlugin
)
->
dict
:
"""
Useful for debugging & development.
...
...
@@ -26,3 +28,17 @@ def variables(env: MacrosPlugin) -> dict:
def
rel_url
(
env
:
MacrosPlugin
,
rel_path
:
str
)
->
str
:
site_url
=
environment
(
env
)[
"
conf
"
][
"
site_url
"
]
return
urljoin
(
site_url
,
rel_path
)
# Generic Macros:
_ENV
=
None
def
define_env
(
env
:
MacrosPlugin
):
global
_ENV
_ENV
=
env
env
.
macro
(
site_url
)
def
site_url
()
->
str
:
env
=
environment
(
_ENV
)
return
env
[
"
conf
"
][
"
site_url
"
]
#return environment(_ENV)["conf"]["site_url"]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment