Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pdf file in releases #2665

Merged
merged 19 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
- name: "Install OS packages"
run: |
sudo apt update
sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex
sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex texlive-fonts-extra qpdf

- name: "Test virtual framebuffer"
run: |
Expand Down Expand Up @@ -824,7 +824,7 @@ jobs:
files: |
./**/*.whl
./**/*.tar.gz
./**/*pymapdl-Documentation-*.pdf
./**/pymapdl*.pdf
./**/ansys-mapdl-core*.zip
./minimum_requirements.txt

Expand Down
5 changes: 3 additions & 2 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ else
endif

@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
python validate_png.py # clean-up GIFs mislabeled as PNG
python post_process_tex.py # post-process latex file after sphinx build and before latex build
cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
(test -f $(BUILDDIR)/latex/pymapdl-Documentation-*.pdf && echo pdf exists) || exit 1
(test -f $(BUILDDIR)/latex/pymapdl-Documentation-*.pdf && echo "pdf exists!") || exit 1
qpdf --check $(BUILDDIR)/latex/pymapdl-Documentation-*.pdf && echo "File is OK" && exit 0 || echo "File is corrupt" && exit 1

linkcheck:
ifeq ($(strip $(MSG)), )
Expand Down
54 changes: 54 additions & 0 deletions doc/post_process_tex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Validate the PNG images in the build/latex/ directory

Removes invalid PNGs (probably GIF)

"""

from glob import glob
import os
from pathlib import Path

from PIL import Image

this_path = os.path.dirname(os.path.abspath(__file__))
check_path = os.path.join(this_path, "_build", "latex")
if not os.path.isdir(check_path):
raise FileNotFoundError(f"Invalid path {check_path}")

for filename in glob(os.path.join(check_path, "*.png")):
im = Image.open(filename)
im.save(filename, format="png")
im.close() # reload is necessary in my case

print("Replacing animated GIFs for static PNGs in Latex")
latex_file = glob(os.path.join(check_path, "*.tex"))[0]

files_to_replace = []

for filename in glob(os.path.join(check_path, "*.gif")):
im = Image.open(filename)

new_file_name = filename.split(".")[0] + ".png"
files_to_replace.append([filename, new_file_name])

im.save(new_file_name, format="png")
im.close() # reload is necessary in my case
print(f"Replaced {filename} with {new_file_name}")

# Replace in tex file
with open(latex_file, "r") as fid:
content = fid.read()

for old_file_name, new_file_name in files_to_replace:
old_file_name = os.path.basename(old_file_name)
new_file_name = os.path.basename(new_file_name)

name = Path(new_file_name).stem # no extension

old_file_pattern = "{{" + f"{name}" + "}.gif}" # {{manifold}.gif}
new_file_pattern = "{{" + f"{name}" + "}.png}" # {{manifold}.gif}

content = content.replace(old_file_pattern, new_file_pattern)

with open(latex_file, "w") as fid:
fid.write(content)
3 changes: 2 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
"ansys-math-core": ("https://math.docs.pyansys.com/version/stable/", None),
}

suppress_warnings = ["label.*"]
suppress_warnings = ["label.*", "design.fa-build"]
sd_fontawesome_latex = True
# supress_warnings = ["ref.option"]

# Graphviz diagrams configuration
Expand Down
Binary file modified doc/source/images/manifold.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 0 additions & 20 deletions doc/validate_png.py

This file was deleted.

Loading