From 7990a19250487e358b8ad0a43c258932d6d563d3 Mon Sep 17 00:00:00 2001 From: Marcin Wojdyr Date: Wed, 4 Dec 2024 12:24:11 +0100 Subject: [PATCH] docs: change theme to Furo, to enable dark mode --- CMakeLists.txt | 2 +- docs/_static/cpp.png | Bin 0 -> 1262 bytes docs/_static/custom.css | 69 ++++++++++++++++++++++++++++++++++++++ docs/_static/py.png | Bin 0 -> 1571 bytes docs/_templates/page.html | 10 ++++++ docs/cif.rst | 26 +++++++------- docs/conf.py | 23 ++++++++----- docs/custom.css | 19 ----------- docs/mol.rst | 24 ++++++------- docs/requirements.txt | 4 +-- run-tests.sh | 3 +- 11 files changed, 125 insertions(+), 55 deletions(-) create mode 100644 docs/_static/cpp.png create mode 100644 docs/_static/custom.css create mode 100644 docs/_static/py.png create mode 100644 docs/_templates/page.html delete mode 100644 docs/custom.css diff --git a/CMakeLists.txt b/CMakeLists.txt index 82511bd85..8fa1959bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,7 +403,7 @@ endif() add_executable(test_disulf EXCLUDE_FROM_ALL tests/disulf.cpp) target_link_libraries(test_disulf PRIVATE gemmi_cpp) -# auth_label requires and -lstdc++fs +# auth_label requires C++17 for add_executable(auth_label EXCLUDE_FROM_ALL examples/auth_label.cpp) target_link_libraries(auth_label PRIVATE gemmi_cpp) diff --git a/docs/_static/cpp.png b/docs/_static/cpp.png new file mode 100644 index 0000000000000000000000000000000000000000..21a9573a556e2188938e15d4c74d30220e388715 GIT binary patch literal 1262 zcmV_BZQJI<+O}=mwr%eY*0%NT#`fA{GpeimuaTba%$Mxcd%vJjUsdo=$K(pN zUKsW@*+wka*haoK6>mxK=gBN$C%6OqwSCVQ*YNE~GJ!U7OuOO~{7(`>V2}{<=lu-+ z2Js*$8shPWJA*$)`jcz|MPy&|e9YD1tB^PX*C5_iToL>;vXj6)$XcJN2>vvgND2tt zOu@CapLRBUQxZ>Lls07YrZ~*meo~mk$Icg#3{8y$|Bm<=U1+dZ6pn-@;8Ic!>~=fu zl#Saia^K<5cntE4a-xW2`mV6>Uy>Xn#sfT}5PB*VR+}9sr z@lpw_tU%Xg5lGK2F!UMEGh3lk;$3gjF?`U<=(r?Yj=5F&1!ipA6O30I zFOhIAE8uzXEVLAUI!*8R<*`x%0byrQrH8k6SXBiAS-EC(Uml_VQe(C+229(b z9a43H_|#lD5-$&Q1#dPd2!Hq4de2a0I(uO4c7Jpmw*|LuuibZzZ0CK^3gnw@aHJ`P zT&%TR5Q+*T_Th!b%N)L{oknjGuQd#N>-G`z_JWf8A{Ee(X878Zj^mRyUYZ|?-ABS@ z3W3VV%*B<&G}#^+bsi~cS)k;e&)rv`@eE)5+HM(46(_<}XTIwTsQL)CoEMDJeK+8# z@?&5sJrY8hQ7~1V22;I7>OVp%zr@u??Zw+QCQImhQkJD^%u@d)Rxw7)cUdMO_3&%M zY3M&y!5CHfL*^eGtGj?-P|PhqWEx*^cV9~Q1VrP#%3~b{f4|CDIp$X7<(si#cMx7` zq~KCQ#l>7wN;+1qJ%G~9rrro%uEjL0T6Yl1+^2alw_u;^3N)SNhswRZILI%r8ivgSQd`0OQjTM{=4?X+tOSjx`{2jci!~?7+AT++O7zm6TootCuX&+= z>YL9A+*-2NIy_Wnl&*0&bI~^WoI5Ewcjn@4;-!l!|9?LgZgp6I2YpF$2=r2^^>p|I zM#E~gL9Z-UE5~URDzuy~9tOyfjFeW1?}!h95vsSFi5>fVarQzyY */ + color: #108080 /* original #408090 is too similar to our background */ +} +.highlight-cpp .highlight .s { /* "strings" */ + color: #107090 /* original #4070a0 */ +} +.highlight-cpp .highlight .mi, +.highlight-cpp .highlight .mf { /* integers and floats */ + color: #008040 /* original #208050 */ +} + +/* In dark mode, instead of changing bg color we add Python logo */ +@media (prefers-color-scheme: dark) { + body:not([data-theme="light"]) .highlight-pycon, + body:not([data-theme="light"]) .highlight-python, + body:not([data-theme="light"]) .highlight-cpp { + position: relative; + } + body:not([data-theme="light"]) .highlight-pycon::after, + body:not([data-theme="light"]) .highlight-python::after, + body:not([data-theme="light"]) .highlight-cpp::after { + content: ""; + background-size: contain; + background-repeat: no-repeat; + width: 24px; + height: 24px; + position: absolute; + top: 5px; /* from the top edge */ + right: 5px; /* from the right edge */ + pointer-events: none; /* no interactions */ + } + body:not([data-theme="light"]) .highlight-pycon::after, + body:not([data-theme="light"]) .highlight-python::after { + background-image: url("../_static/py.png"); + opacity: 0.5; + } + body:not([data-theme="light"]) .highlight-cpp::after { + background-image: url("../_static/cpp.png"); + opacity: 0.6; + } +} + +/* roles used in mol.rst */ +.orange-fg { color:#d50; } +.blue-bg { background-color:#ace; } +/* roles used in cif.rst */ +.orange-bg { background-color:#fc8; } +.yellow-bg { background-color:#ffa; } +.cyan-bg { background-color:#aff; } +.greenish-bg { background-color:#bd8; } +@media (prefers-color-scheme: dark) { + body:not([data-theme="light"]) .blue-bg { background-color:#138; } + body:not([data-theme="light"]) .orange-bg { background-color:#950; } + body:not([data-theme="light"]) .yellow-bg { background-color:#660; } + body:not([data-theme="light"]) .cyan-bg { background-color:#055; } + body:not([data-theme="light"]) .greenish-bg { background-color:#350; } +} diff --git a/docs/_static/py.png b/docs/_static/py.png new file mode 100644 index 0000000000000000000000000000000000000000..a96ccd13ca498cb4e38ba0f1b0e9490f0291317c GIT binary patch literal 1571 zcmV+;2Hg3HP)x{Ny3 zn5p~USe5Vqbw)L5pkm07uN4g#@^hPi_d9x;awzaO9Z;0rC3Wff*8>R;Qd5hhP@xJ` zGS>}nxDUDjx*YIpZ2^{Lz11IQys6avtK@wQc^X|*oehPigmY0{8}qAY0_)cn5C(P7 zSXM1m!0S^=YmrhwIgoDeRTpZJY`!v8tOFbcyiuktD0%)>&`Tpv68c(Q8tJ|nhMaI0@>NNUW zK=aE-P%l)PO^MpOfg_r$LtPpwwWAGFRuOqGkh!i#bh3p$LZ1Zz(WXEYRMakYRy3i| zoMbdth1wJ-b@=X!&yEC+qz#50VfYb|Z`DEVR7RoC9++VADF>I~3L1;6lc)oU7DkK~ z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gzgeEAS=o7VsP?Jw#X6OF&5<`5*Md VV6PtkAs7Gv002ovPDHLkV1k%g%AWuL literal 0 HcmV?d00001 diff --git a/docs/_templates/page.html b/docs/_templates/page.html new file mode 100644 index 000000000..bd727628c --- /dev/null +++ b/docs/_templates/page.html @@ -0,0 +1,10 @@ +{% extends "!page.html" %} + +{% block footer %} +{# Copyright and (c) are redundant, leave only (c) #} +{{ super() | replace('Copyright ', '') + | replace('Made with', 'Built with') + | replace('@pradyunsg\'s', + 'customized theme') +}} +{% endblock %} diff --git a/docs/cif.rst b/docs/cif.rst index ec4c13d23..319153687 100644 --- a/docs/cif.rst +++ b/docs/cif.rst @@ -1666,20 +1666,20 @@ some columns seem to be completely redundant. Are they? .. raw:: html - +
- + - - + + - + - - - - + + + + @@ -1811,7 +1811,7 @@ We compile it, run it, and come back after an hour: .. code-block:: none - $ g++-6 -O2 -Iinclude examples/auth_label.cpp -lstdc++fs -lz + $ g++ -O2 -Iinclude examples/auth_label.cpp src/gz.cpp -lz $ ./a.out pdb_copy/mmCIF 3D3W: atom_id O1 -> OD 1TNI: atom_id HN2 -> HN3 @@ -1844,8 +1844,10 @@ We compile it, run it, and come back after an hour: 1AGG: atom_id H3 -> H 1AGG: atom_id H3 -> H -So, as of April 2017, only a single author's residue name was changed, -and atom names were changed in 7 PDB entries. +Update: the result above is from 2017. +In the meantime, the PDB removed the differences. +Tags auth_atom_id and auth_comp_id are now completely redundant +(they always have been, except for mistakes). Amino acid frequency -------------------- diff --git a/docs/conf.py b/docs/conf.py index 7b20925dc..f20d978f4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,13 +2,12 @@ # -- General configuration ------------------------------------------------ +# while we use Sphinx 8+, old version suffices to run doctests needs_sphinx = '5.3.0' extensions = ['sphinx.ext.doctest', 'sphinx.ext.githubpages'] -#templates_path = ['_templates'] - -source_suffix = '.rst' +templates_path = ['_templates'] master_doc = 'index' @@ -25,14 +24,24 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] pygments_style = 'sphinx' todo_include_todos = False -highlight_language = 'c++' +highlight_language = 'cpp' default_role = 'literal' # -- Options for HTML output ---------------------------------------------- -html_theme = 'sphinx_rtd_theme' -html_static_path = ['custom.css'] +html_theme = 'furo' +html_theme_options = { + "source_repository": "https://github.com/project-gemmi/gemmi/", + "source_branch": "master", + "source_directory": "docs/", +} +html_static_path = ['_static'] +html_css_files = ['custom.css'] + +# Edit link can be also used to see the source +html_show_sourcelink = False +html_copy_source = False # -- Options for LaTeX output --------------------------------------------- @@ -91,5 +100,3 @@ gemmi.set_leak_warnings(False) ''' -def setup(app): - app.add_css_file('custom.css') diff --git a/docs/custom.css b/docs/custom.css deleted file mode 100644 index da4be8f0f..000000000 --- a/docs/custom.css +++ /dev/null @@ -1,19 +0,0 @@ - -.highlight-pycon .highlight, .highlight-pycon3 .highlight, .highlight-python .highlight { - background: #fcfcce; -} -.highlight-cpp .highlight { - background: #e2ffef; -} -.highlight-cpp .highlight .cl { - color: #486878 -} - -/* overwrite 12px margin that adds extra spacing before a nested list */ -.rst-content .section ul p { margin-bottom: 0; } -/* in sphinx_rtd_theme=1.0 this works, but only in Contents */ -.rst-content .section ul li > p { margin-bottom: 0; } - -/* roles used in mol.rst */ -.orange-fg { color:#d50; } -.blue-bg { background-color:#ace; } diff --git a/docs/mol.rst b/docs/mol.rst index 0d634be53..072175025 100644 --- a/docs/mol.rst +++ b/docs/mol.rst @@ -1068,26 +1068,26 @@ So once again, now in a color-coded version: .. raw:: html -
- ATOM   1032 O OE2 . GLU B 2  72  ? -9.804  19.834  -55.805 1.00 25.54 ? 77   GLU H OE2 1
- ATOM   1033 N N   A ARG B 2  73  A -4.657  24.646  -55.236 0.11 20.46 ? 77   ARG H N   1
- ATOM   1034 N N   B ARG B 2  73  A -4.641  24.646  -55.195 0.82 22.07 ? 77   ARG H N   1
+ 
+ ATOM   1032 O OE2 . GLU B 2  72  ? -9.804  19.834  -55.805 1.00 25.54 ? 77   GLU H OE2 1
+ ATOM   1033 N N   A ARG B 2  73  A -4.657  24.646  -55.236 0.11 20.46 ? 77   ARG H N   1
+ ATOM   1034 N N   B ARG B 2  73  A -4.641  24.646  -55.195 0.82 22.07 ? 77   ARG H N   1
  
and a couple lines from another file (6any): .. raw:: html -
- ATOM   1    N N   . PHE A 1 1   ? 21.855 30.874 0.439  1.00 29.16 ? 17  PHE A N   1 
- ATOM   2    C CA  . PHE A 1 1   ? 20.634 31.728 0.668  1.00 26.60 ? 17  PHE A CA  1
+ 
+ ATOM   1    N N   . PHE A 1 1   ? 21.855 30.874 0.439  1.00 29.16 ? 17  PHE A N   1 
+ ATOM   2    C CA  . PHE A 1 1   ? 20.634 31.728 0.668  1.00 26.60 ? 17  PHE A CA  1
 
- ATOM   1630 C CD2 . LEU A 1 206 ? 23.900 18.559 1.006  1.00 16.97 ? 222 LEU A CD2 1 
- HETATM 1631 C C1  . NAG B 2 .   ? 5.126  22.623 37.322 1.00 30.00 ? 301 NAG A C1  1 
- HETATM 1632 C C2  . NAG B 2 .   ? 5.434  21.608 38.417 1.00 30.00 ? 301 NAG A C2  1
+ ATOM   1630 C CD2 . LEU A 1 206 ? 23.900 18.559 1.006  1.00 16.97 ? 222 LEU A CD2 1 
+ HETATM 1631 C C1  . NAG B 2 .   ? 5.126  22.623 37.322 1.00 30.00 ? 301 NAG A C1  1 
+ HETATM 1632 C C2  . NAG B 2 .   ? 5.434  21.608 38.417 1.00 30.00 ? 301 NAG A C2  1
 
- HETATM 1709 O O   . HOH I 6 .   ? -4.171 14.902 2.395  1.00 33.96 ? 401 HOH A O   1 
- HETATM 1710 O O   . HOH I 6 .   ? 9.162  43.925 8.545  1.00 21.30 ? 402 HOH A O   1
+ HETATM 1709 O O   . HOH I 6 .   ? -4.171 14.902 2.395  1.00 33.96 ? 401 HOH A O   1 
+ HETATM 1710 O O   . HOH I 6 .   ? 9.162  43.925 8.545  1.00 21.30 ? 402 HOH A O   1
  
.. role:: orange_fg diff --git a/docs/requirements.txt b/docs/requirements.txt index fbe550da7..52dbbc035 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,2 @@ -sphinx_rtd_theme >= 1.0.0 -sphinx >= 5.3.0 +sphinx >= 8.1.3 +furo >= 2024.8.6 diff --git a/run-tests.sh b/run-tests.sh index 5386d9029..8f114a829 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -49,7 +49,8 @@ grep :: $BUILD_DIR/py/gemmi/*.pyi ||: if [ -z "${NO_DOCTEST-}" ]; then # 'make doctest' works only if sphinx-build was installed for python3. - (cd docs && make doctest SPHINXOPTS="-q -n") + #(cd docs && make doctest SPHINXOPTS="-q -n") + (cd docs && $PYTHON -m sphinx -M doctest . _build -q -n) fi # Usually, we stop here. Below are more extensive checks below that are run