Skip to content

Commit d9d89ab

Browse files
committed
Add French PDF manuals as download links
1 parent 5e10d37 commit d9d89ab

File tree

7 files changed

+65
-38
lines changed

7 files changed

+65
-38
lines changed

source/docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Documentation
88
| **Release Date:** Sunday, 1 June 2025
99
| **Docs Updated:** Sunday, 1 June 2025
1010
11-
**PDF:** :download:`novelWriter-2.7.pdf <../more/novelWriter-2.7.pdf>` [ :ref:`Older Versions <more_docs>` ]
11+
**PDF:** :download:`novelWriter-2.7.pdf <../more/novelWriter-2.7.pdf>` [ :ref:`Other Versions <more_docs>` ]
1212

1313
novelWriter is an open source plain text editor designed for writing novels assembled from
1414
individual text documents. It uses a minimal formatting syntax inspired by Markdown, and adds a

source/more/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ A selection of PDF manuals are available here for download, including for earlie
2222
| :download:`novelWriter-2.0.pdf`
2323
| :download:`novelWriter-1.6.pdf`
2424
25+
Translated PDF Manuals
26+
----------------------
27+
28+
| :download:`novelWriter-fr-2.7.pdf`
29+
| :download:`novelWriter-fr-2.6.pdf`
30+
2531

2632
For Developers
2733
==============

source/more/novelWriter-2.7.pdf

0 Bytes
Binary file not shown.

source/more/novelWriter-fr-2.6.pdf

2.59 MB
Binary file not shown.

source/more/novelWriter-fr-2.7.pdf

2.07 MB
Binary file not shown.

templates/more_docs.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ A selection of PDF manuals are available here for download, including for earlie
1414

1515
{doc_pdfs}
1616

17+
Translated PDF Manuals
18+
----------------------
19+
20+
{doc_pdfs_i18n}
21+
1722

1823
For Developers
1924
==============

tools/docs.py

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Custom code to handle documentation versions from the main repo.
33
"""
44

5+
import os
56
import shutil
67
import subprocess
78
import urllib.request
@@ -104,51 +105,68 @@ def writeDocsCopy(self):
104105
##
105106

106107
def _buildPdfManual(self):
107-
"""This function will build the documentation as manual.pdf."""
108-
buildDir = str(self._extPath / "docs")
109-
buildFile = self._extPath / "docs" / "build" / "latex" / "manual.pdf"
110-
buildFile.unlink(missing_ok=True)
111-
112-
print("Building PDF manual ... ", end="")
113-
subprocess.call(["make", "clean"], cwd=buildDir)
114-
exCode = subprocess.call(
115-
["make", "latexpdf"], cwd=buildDir,
116-
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT
117-
)
118-
if exCode != 0:
119-
raise Exception(f"Build returned error code {exCode}")
120-
121-
if buildFile.exists():
122-
newDoc = self._pdfPath / f"novelWriter-{self._nwMajor}.{self._nwMinor}.pdf"
123-
newDoc.unlink(missing_ok=True)
124-
buildFile.rename(newDoc)
125-
print("Done")
126-
else:
127-
print("FAILED")
108+
"""Build the documentation as manual.pdf."""
109+
docsDir = self._extPath / "docs"
110+
locsDir = self._extPath / "docs" / "source" / "locales"
111+
pdfFile = self._extPath / "docs" / "build" / "latex" / "manual.pdf"
112+
locsDir.mkdir(exist_ok=True)
113+
114+
build = ["en"] + [i.stem for i in locsDir.iterdir() if i.is_dir()]
115+
116+
for code in build:
117+
print(f"Building PDF manual ({code}) ... ", end="", flush=True)
118+
env = os.environ.copy()
119+
cmd = "make clean latexpdf"
120+
name = "novelWriter"
121+
if code != "en":
122+
data = (locsDir / f"authors_{code}.conf").read_text(encoding="utf-8")
123+
authors = [x for x in data.splitlines() if x and not x.startswith("#")]
124+
env["SPHINX_I18N_AUTHORS"] = ", ".join(authors)
125+
cmd += f" -e SPHINXOPTS=\"-D language='{code}'\""
126+
name = f"novelWriter-{code}"
127+
128+
if subprocess.call(cmd, cwd=docsDir, env=env, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) == 0:
129+
newDoc = self._pdfPath / f"{name}-{self._nwMajor}.{self._nwMinor}.pdf"
130+
newDoc.unlink(missing_ok=True)
131+
pdfFile.rename(newDoc)
132+
print("Done")
133+
else:
134+
print("FAILED")
128135

129136
return
130137

131138
def _createPdfPage(self):
132139
"""Create the index of PDF manuals."""
133-
pdfs = []
140+
pdfs: list[tuple[str, str, str, str]] = []
134141
for item in self._pdfPath.iterdir():
135142
if item.is_file() and item.suffix == ".pdf":
136-
_, _, version = item.stem.partition("-")
137-
key = ".".join(version.split(".")[:2])
138-
pdfs.append((key, item.name))
139-
140-
docsPDF = []
141-
specPDF = []
142-
for _, pdf in sorted(pdfs, key=lambda x: x[0], reverse=True):
143-
if pdf.startswith("novelWriter"):
144-
docsPDF.append(pdf)
145-
elif pdf.startswith("FileFormat"):
146-
specPDF.append(pdf)
143+
kind, _, spec = item.stem.partition("-")
144+
one, _, two = spec.partition("-")
145+
if two:
146+
lang = one
147+
version = ".".join(two.split(".")[:2])
148+
else:
149+
lang = "en"
150+
version = ".".join(one.split(".")[:2])
151+
pdfs.append((kind, lang, version, item.name))
152+
153+
docsPdfEn = []
154+
docsPdfTr = []
155+
specPdfEn = []
156+
for kind, lang, version, pdf in sorted(pdfs, key=lambda x: x[2], reverse=True):
157+
if kind == "novelWriter":
158+
if lang == "en":
159+
docsPdfEn.append(pdf)
160+
else:
161+
docsPdfTr.append(pdf)
162+
elif kind == "FileFormatSpec":
163+
specPdfEn.append(pdf)
147164

148165
with open(self._pdfPath / "index.rst", mode="w", encoding="utf-8") as of:
149166
of.write((self._tplPath / "more_docs.rst").read_text(encoding="utf-8").format(
150-
doc_pdfs="\n".join(f"| :download:`{pdf}`" for pdf in docsPDF),
151-
spec_pdfs="\n".join(f"| :download:`{pdf}`" for pdf in specPDF),
167+
doc_pdfs="\n".join(f"| :download:`{pdf}`" for pdf in docsPdfEn),
168+
doc_pdfs_i18n="\n".join(f"| :download:`{pdf}`" for pdf in docsPdfTr),
169+
spec_pdfs="\n".join(f"| :download:`{pdf}`" for pdf in specPdfEn),
152170
))
153171

154172
return
@@ -241,5 +259,3 @@ def _extractReleaseInfo(self):
241259
print("Done")
242260

243261
return
244-
245-
# END Class Documentation

0 commit comments

Comments
 (0)