diff --git a/Makefile b/Makefile index bcc15dc..38e4985 100644 --- a/Makefile +++ b/Makefile @@ -19,5 +19,11 @@ help: %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +# We clear the html folder before rebuilding, otherwise some things are +# not updated (like static files) +html: + rm -rf "$(BUILDDIR)/html" + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + pdf: weasyprint python3 sphinx-tools/make_pdf.py "$(SOURCEDIR)" "$(BUILDDIR)" diff --git a/source/_static/custom.css b/source/_static/custom.css new file mode 100644 index 0000000..5d9a284 --- /dev/null +++ b/source/_static/custom.css @@ -0,0 +1,31 @@ +.document-title { + width: 100%; + color: #fbbb15; + text-align: center; + font-size: 5em !important; + border-top: 2px solid black; + border-bottom: 2px solid black; + line-height: 1.2; + font-weight: bold; +} + +.document-subtitle { + text-align: center; + font-size: 1.5em; + margin-top: 30px; + margin-bottom: 30px; +} + +.title-page-footer { + text-align: center; + font-size: 1.2em !important; + margin-top: 30px; +} + +/* displayed as a title, but doesn't count in numbering and doesn't appear in TOC */ +.fake-title { + font-weight: 700; + font-size: 175% !important; + font-family: Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif; + break-before: always; +} diff --git a/source/conf.py b/source/conf.py index 8ce90cb..64627fc 100644 --- a/source/conf.py +++ b/source/conf.py @@ -48,6 +48,11 @@ templates_path = ['_templates'] # -- Options for HTML output html_theme = 'sphinx_rtd_theme' +html_title = 'Vhéliotech' +html_static_path = ['_static'] +html_css_files = [ + 'custom.css', +] # -- Options for EPUB output epub_show_urls = 'footnote' diff --git a/source/css/print-theme.css b/source/css/print-theme.css index 455b15f..868222f 100644 --- a/source/css/print-theme.css +++ b/source/css/print-theme.css @@ -39,38 +39,6 @@ div[role=navigation], .headerlink { display: none; } -.document-title { - width: 100%; - color: #fbbb15; - text-align: center; - font-size: 5em !important; - border-top: 2px solid black; - border-bottom: 2px solid black; - line-height: 1.2; - font-weight: bold; -} - -.document-subtitle { - text-align: center; - font-size: 1.5em; - margin-top: 30px; - margin-bottom: 30px; -} - -.title-page-footer { - text-align: center; - font-size: 1.2em !important; - margin-top: 30px; -} - -/* displayed as a title, but doesn't count in numbering and doesn't appear in TOC */ -.fake-title { - font-weight: 700; - font-size: 175% !important; - font-family: Roboto Slab,ff-tisa-web-pro,Georgia,Arial,sans-serif; - break-before: always; -} - h1 { break-before: always; } diff --git a/source/index.md b/source/index.md index 24eea59..54841f1 100644 --- a/source/index.md +++ b/source/index.md @@ -43,6 +43,7 @@ Copyright Vélo Solaire Pour Tous, Mai 2023, sous [licence CERN-OHL-S version 2] ```{toctree} +:maxdepth: 2 010_documentation 020_moyens_necessaires 030_plan_general @@ -57,3 +58,10 @@ Copyright Vélo Solaire Pour Tous, Mai 2023, sous [licence CERN-OHL-S version 2] 110_accessoires 120_tests_verifications ``` + + diff --git a/sphinx-tools/make_pdf.py b/sphinx-tools/make_pdf.py index e7f7b7e..f59e402 100644 --- a/sphinx-tools/make_pdf.py +++ b/sphinx-tools/make_pdf.py @@ -15,7 +15,8 @@ css_filename = source_dir + '/css/print-theme.css' script_dir = os.path.dirname(__file__) # Compile PDF -assert(subprocess.run(['weasyprint', build_dir + '/weasyprint/index.html', index_pdf_filename, '-s', css_filename]).returncode == 0) +pdf_compile_command = ['weasyprint', build_dir + '/weasyprint/index.html', index_pdf_filename, '-s', source_dir + '/_static/custom.css', '-s', css_filename] +assert(subprocess.run(pdf_compile_command).returncode == 0) # Generate table of content (TOC) assert(subprocess.run(['sh', '-c', script_dir + '/../pdftoc-to-latex "' + index_pdf_filename + '" > "' + build_dir + '/weasyprint/toc.tex"']).returncode == 0) @@ -49,7 +50,7 @@ if modified_css != original_css: # We need to compile again with the modified CSS (this won't impact the TOC) print('Number of pages has changed, rebuilding PDF...') - assert(subprocess.run(['weasyprint', build_dir + '/weasyprint/index.html', index_pdf_filename, '-s', css_filename]).returncode == 0) + assert(subprocess.run(pdf_compile_command).returncode == 0) # Insert TOC in the PDF assert(subprocess.run(['pdftk', 'A='+index_pdf_filename, 'B='+build_dir+'/weasyprint/toc.pdf', 'cat', 'A1-'+str(insert_toc_after_page), 'B', 'A'+str(insert_toc_after_page+1)+'-end', 'output', build_dir + '/weasyprint/vheliotech-without-bookmarks.pdf']).returncode == 0)