Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Reduce generated docs size (#7)
Browse files Browse the repository at this point in the history
* update version
* use shared .doctrees folder outside of docs
* replace duplicated versioned files with symlinks
  • Loading branch information
kukushechkin authored Feb 3, 2023
1 parent 0dfce59 commit cd6dfa0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Changelog
Version 0.2
===========

Version 0.2.11 (2023-02-02)
--------------------------
* Reduce docs size.


Version 0.2.10 (2023-01-13)
--------------------------
* Try extracting the version from the git tag if it exists and sort based on that. Clients can configure an optional ``smv_symver_pattern`` if default patter is not suitable.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

author = "Jan Holthuis"
project = "sphinx-multiversion"
release = "0.2.10"
release = "0.2.11"
version = "0.2"
copyright = "{}, {}".format(time.strftime("%Y"), author)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
author="Jan Holthuis",
author_email="[email protected]",
url="https://github.com/iqm-finland/sphinx-multiversion-contrib",
version="0.2.10",
version="0.2.11",
install_requires=["sphinx >= 2.1"],
license="BSD",
packages=["sphinx_multiversion"],
Expand Down
24 changes: 23 additions & 1 deletion sphinx_multiversion/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
import tempfile
import datetime
import filecmp

from sphinx import config as sphinx_config
from sphinx import project as sphinx_project
Expand Down Expand Up @@ -261,7 +262,10 @@ def main(argv=None):
logger = logging.getLogger(__name__)
released_versions = []

with tempfile.TemporaryDirectory() as tmp:
with (
tempfile.TemporaryDirectory() as tmp,
tempfile.TemporaryDirectory() as doctree_cache
):
# Generate Metadata
metadata = {}
outputdirs = set()
Expand Down Expand Up @@ -416,6 +420,8 @@ def main(argv=None):
*get_python_flags(),
"-m",
"sphinx",
"-d",
doctree_cache,
*current_argv,
)
current_cwd = os.path.join(data["basedir"], cwd_relative)
Expand All @@ -432,4 +438,20 @@ def main(argv=None):
)
subprocess.check_call(cmd, cwd=current_cwd, env=env)

# check if there are any files in the versioned output directories identical to files in the root dev output directory and replace them with symlinks
if args.dev_name:
dev_outputdir = metadata[args.dev_name]['outputdir']
for version_name, data in metadata.items():
if version_name == args.dev_name:
continue
version_outputdir = data['outputdir']
for root, dirs, files in os.walk(version_outputdir):
for file in files:
dev_file_path = os.path.join(dev_outputdir, os.path.relpath(root, version_outputdir), file)
# check files are identical
if os.path.exists(dev_file_path) and filecmp.cmp(os.path.join(root, file), dev_file_path):
version_file_path = os.path.join(root, file)
os.remove(version_file_path)
os.symlink(dev_file_path, version_file_path)

return 0

0 comments on commit cd6dfa0

Please sign in to comment.