Skip to content

Commit

Permalink
doc: dynamic version number management
Browse files Browse the repository at this point in the history
  • Loading branch information
florentfgrs committed Oct 9, 2024
1 parent 5e4d8b7 commit e782b2c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Binary file modified website/__pycache__/macros.cpython-312.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions website/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SFCGAL

![]( assets/img/logo.svg)
![](assets/img/logo.svg)

## Downloads

[Download this project as a .zip file](https://gitlab.com/SFCGAL/SFCGAL/-/archive/v{{ current_version }}/SFCGAL-v{{ current_version }}.zip){ .md-button .md-button--primary }
[Download this project as a tar.gz file](https://gitlab.com/SFCGAL/SFCGAL/-/archive/v{{ current_version }}/SFCGAL-v{{ current_version }}.tar.gz){ .md-button .md-button--primary }
[Download this project as a .zip file](https://gitlab.com/SFCGAL/SFCGAL/-/archive/v{{ get_project_version() }}/SFCGAL-v{{ get_project_version() }}.zip){ .md-button .md-button--primary }
[Download this project as a tar.gz file](https://gitlab.com/SFCGAL/SFCGAL/-/archive/v{{ get_project_version() }}/SFCGAL-v{{ get_project_version() }}.tar.gz){ .md-button .md-button--primary }

## About

Expand Down
2 changes: 1 addition & 1 deletion website/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SFCGAL source code is available on the corresponding [GitLab repository](https:/

The `master` branch is the development branch and has a tag for each released version.

Source code of the {{ current_version }} release can be found with the tag v{{ current_version }}. You can directly download a [zip](https://gitlab.com/SFCGAL/SFCGAL/-/archive/v{{ current_version }}/SFCGAL-v{{ current_version }}.zip) or [tarball](https://gitlab.com/SFCGAL/SFCGAL/-/archive/v{{ current_version }}/SFCGAL-v{{ current_version }}.tar.gz).
Source code of the {{ get_project_version() }} release can be found with the tag v{{ get_project_version() }}. You can directly download a [zip](https://gitlab.com/SFCGAL/SFCGAL/-/archive/v{{ get_project_version() }}/SFCGAL-v{{ get_project_version() }}.zip) or [tarball](https://gitlab.com/SFCGAL/SFCGAL/-/archive/v{{ get_project_version() }}/SFCGAL-v{{ get_project_version() }}.tar.gz).

## Supported platforms

Expand Down
19 changes: 19 additions & 0 deletions website/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,22 @@ def include_file(filename: str) ->str:
return content
except FileNotFoundError:
return f"File not found: {filename}"

@env.macro
def get_project_version() -> str:
"""Retrieve the project version from sonar-project.properties.
Returns:
str: The project version if found, or an error message if the file
cannot be read or the version is not specified.
"""
properties_file = "../sonar-project.properties"
try:
with open(properties_file, "r", encoding="utf-8") as file:
for line in file:
if line.startswith("sonar.projectVersion="):
# Extract and return the version number
return line.split("=", 1)[1].strip()
return "Version not found in the properties file."
except FileNotFoundError:
return f"File not found: {properties_file}"
3 changes: 0 additions & 3 deletions website/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ site_name: SFCGAL
repo_name: "SFCGAL"
repo_url: "https://gitlab.com/sfcgal/SFCGAL/"

extra:
current_version: 1.5.2

theme:
name: material
features:
Expand Down

0 comments on commit e782b2c

Please sign in to comment.