Skip to content

Commit

Permalink
Add proper version information in quick-links page
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
pedro-psb committed Jul 29, 2024
1 parent 7ae0eb1 commit d726a19
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
29 changes: 28 additions & 1 deletion docs/sections/help/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ Don't hesitate to contact us!

---

## Quick Links (WIP)
## Quick Links

!!! note "About versions"

The `version` column is the latest on main and it's what we publish.

You might encounter some unreleased content live, but plugins usually release often.
Also, we try to include version information on the docs itself.

### Content Plugins

{% for repo_type in ("core", "content") %}
Repo | Version | Links |   |  
Expand All @@ -21,6 +30,24 @@ Repo | Version | Links |   |  
{% endfor %}
{% endfor %}

### Deployment

Repo | Version | Links |  
--- | --- | --- | ---
{% for repo in get_repos("deployment") -%}
{{ repo.title }} | `{{ repo.version }}` | {{ repo.codebase_link }} | {{ repo.changes_link }}
{% endfor %}

### Interaction

Repo | Version | Links |  
--- | --- | --- | ---
{% for repo in get_repos("interaction") -%}
{{ repo.title }} | `{{ repo.version }}` | {{ repo.codebase_link }} | {{ repo.changes_link }}
{% endfor %}

### Others

Repo | Version | Links |  
--- | --- | --- | ---
{% for repo in get_repos("other") -%}
Expand Down
11 changes: 8 additions & 3 deletions src/pulp_docs/mkdocs_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def prepare_repositories(TMPDIR: Path, repos: Repos, config: Config):
)
else:
this_src_dir = repo_sources / repo_or_pkg.subpackage_of / repo_or_pkg.name
repo_or_pkg.version = f"same as {repo_or_pkg.subpackage_of}"

# restapi
if has_restapi(repo_or_pkg):
Expand Down Expand Up @@ -432,16 +433,20 @@ def get_repos(repo_type="content"):
)
repos_data = [
{
"title": repo.title,
"version": "3.12.1",
"title": "[{title}](site:{name}/)".format(
title=repo.title, name=repo.name
),
"version": repo.version or "unknonwn",
"restapi_link": MD_LINK.format(
title="REST API", path=f"{repo.name}/restapi/"
),
"changes_link": MD_LINK.format(
title="Changelog", path=f"{repo.name}/changes/"
),
"codebase_link": GITHUB_LINK.format(
title="Codebase", owner=repo.owner, name=repo.name
title="Repository",
owner=repo.owner or "pulp",
name=getattr(repo, "subpackage_of", repo.name),
),
}
for repo in repos_list
Expand Down
23 changes: 20 additions & 3 deletions src/pulp_docs/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from pathlib import Path

import httpx
import configparser
import tomli
import yaml

from pulp_docs.utils.general import get_git_ignored_files
Expand Down Expand Up @@ -64,6 +66,7 @@ class Repo:
status: RepoStatus = field(default_factory=lambda: RepoStatus())
type: t.Optional[str] = None
dev_only: bool = False
version: t.Optional[str] = None

def __post_init__(self):
self.branch_in_use = self.branch_in_use or self.branch
Expand Down Expand Up @@ -139,6 +142,22 @@ def download(
dirs_exist_ok=True,
)

# get version
version_file = src_copy_path / ".bumpversion.cfg"
if version_file.exists():
config = configparser.ConfigParser()
config.read(version_file)
self.version = config["bumpversion"]["current_version"]
else:
version_file = src_copy_path / "pyproject.toml"
if version_file.exists():
content = tomli.loads(version_file.read_text())
self.version = (
content.get("tool", {})
.get("bumpversion", {})
.get("current_version")
)

self.status.download_source = str(download_from)
return self.status.download_source

Expand Down Expand Up @@ -211,9 +230,7 @@ class SubPackage:
branch = ""
owner = ""
dev_only: bool = False

def __post_init__(self):
self.owner = self.subpackage_of
version: t.Optional[str] = None


@dataclass
Expand Down

0 comments on commit d726a19

Please sign in to comment.