Skip to content

Commit

Permalink
Fix multiversion build (#279)
Browse files Browse the repository at this point in the history
---------
Co-authored-by: Christoph Kuhnke <[email protected]>
  • Loading branch information
Nicoretti authored Nov 18, 2024
1 parent 70456d8 commit 2b6585b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 🐞 Fixed

* Fixed the issue with publishing new documentation after releasing a new version
* Fixed the issue where master/main was not part of the multiversion documentation

## ✨ Added

* #149: Added nox task to lint imports
Expand Down
27 changes: 21 additions & 6 deletions exasol/toolbox/sphinx/multiversion/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def load_sphinx_config_worker(q, confpath, confoverrides, add_defaults):
)
current_config.add(
"smv_branch_whitelist",
sphinx.DEFAULT_TAG_WHITELIST,
sphinx.DEFAULT_BRANCH_WHITELIST,
"html",
str,
)
Expand Down Expand Up @@ -228,6 +228,11 @@ def _create_parser():
action="store_true",
help="dump generated metadata and exit",
)
parser.add_argument(
"--debug",
action="store_true",
help="enable debug mode with increased log verbosity, etc."
)
return parser


Expand All @@ -247,6 +252,8 @@ def main(argv=None):


def _main(args, argv):
if args.debug:
logger.setLevel(logging.DEBUG)
sourcedir_absolute = os.path.abspath(args.sourcedir)
confdir_absolute = (
os.path.abspath(args.confdir)
Expand Down Expand Up @@ -279,13 +286,13 @@ def _main(args, argv):
conffile = os.path.join(confdir, "conf.py")

# Get git references
gitrefs = git.get_refs(
gitrefs = list(git.get_refs(
str(gitroot),
config.smv_tag_whitelist,
config.smv_branch_whitelist,
config.smv_remote_whitelist,
files=(sourcedir, conffile),
)
))

# Order git refs
if config.smv_prefer_remote_refs:
Expand Down Expand Up @@ -574,14 +581,22 @@ def _main(args, argv):
with open(
os.path.join(args.outputdir, "index.html"), "w", encoding="utf-8"
) as f:
versions = [
logger.debug("Picked up Git references: %s", [ref.name for ref in gitrefs])
tag_versions = [
ref.name
for ref in gitrefs
if re.match(config.smv_tag_whitelist, ref.name)
]
versions = sorted(
versions, key=lambda v: ExasolVersion.from_string(v), reverse=True
tag_versions = sorted(
tag_versions, key=lambda v: ExasolVersion.from_string(v), reverse=True
)
branches = [
ref.name
for ref in gitrefs
if re.match(config.smv_branch_whitelist, ref.name)
]
versions = branches + tag_versions
logger.debug("Selected versions for documentation: %s", versions)
f.write(template.render(version=versions[0]))

return 0
2 changes: 1 addition & 1 deletion exasol/toolbox/sphinx/multiversion/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

DATE_FMT = "%Y-%m-%d %H:%M:%S %z"
DEFAULT_TAG_WHITELIST = r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$"
DEFAULT_BRANCH_WHITELIST = r"master|main"
DEFAULT_BRANCH_WHITELIST = r"^(master|main)"
DEFAULT_REMOTE_WHITELIST = None
DEFAULT_RELEASED_PATTERN = r"^tags/.*$"
DEFAULT_OUTPUTDIR_FORMAT = r"{ref.name}"
Expand Down

0 comments on commit 2b6585b

Please sign in to comment.