From 916d7c31c7ff5b6e244cbd698752210754cc8bb4 Mon Sep 17 00:00:00 2001 From: Zhilin Zheng Date: Thu, 19 Oct 2023 17:28:57 +0800 Subject: [PATCH 1/7] Update README.rst remove python-sphinx, which can not be found by apt-get --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 26e76ea5b..c2043e53a 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,7 @@ Build Install prerequisites:: - sudo apt-get install python-sphinx texlive-fonts-recommended texlive-latex-extra texlive-fonts-extra dvipng + sudo apt-get install texlive-fonts-recommended texlive-latex-extra texlive-fonts-extra dvipng To build the book, do:: From 142cc6d9a6ffefac604bec3376033b63a1fe3252 Mon Sep 17 00:00:00 2001 From: ZhengZhilin Date: Thu, 19 Oct 2023 18:04:37 +0800 Subject: [PATCH 2/7] add features --- README.rst | 14 +++++++++++++- environment.yml | 2 ++ src/_static/css/no_width_limit_n_autowrap_code.css | 8 ++++++++ src/conf.py | 12 ++++++++++-- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/_static/css/no_width_limit_n_autowrap_code.css diff --git a/README.rst b/README.rst index 26e76ea5b..362e7e063 100644 --- a/README.rst +++ b/README.rst @@ -24,12 +24,24 @@ To build the book, do:: This builds both html and pdf versions, that you can find in the _build directory. +For mac user +------------ + +prerequisites:: + +- [port](https://www.macports.org/install.php) to install dvisvgm +- [homebrew](https://brew.sh/) to install texlive +- [conda](https://www.anaconda.com/download) to install sphinx and related extensions + + + Build Using Conda ----------------- Conda build:: - mamba env create -f environment.yml + conda env create -f environment.yml + # mamba env create -f environment.yml # only if you have mamba installed conda activate tprbook make latex tectonic _build/latex/theoretical-physics.tex diff --git a/environment.yml b/environment.yml index 808d19ca6..7ab5dad59 100644 --- a/environment.yml +++ b/environment.yml @@ -6,3 +6,5 @@ dependencies: - myst-parser=1.0.0 - sphinx=6.1.3 - tectonic=0.12.0 + - sphinx-copybutton + - pydata-sphinx-theme \ No newline at end of file diff --git a/src/_static/css/no_width_limit_n_autowrap_code.css b/src/_static/css/no_width_limit_n_autowrap_code.css new file mode 100644 index 000000000..f391fab16 --- /dev/null +++ b/src/_static/css/no_width_limit_n_autowrap_code.css @@ -0,0 +1,8 @@ +.wy-nav-content { + max-width: none; +} + +pre { + white-space: pre-wrap !important; + word-break: break-all; +} \ No newline at end of file diff --git a/src/conf.py b/src/conf.py index 7d1cd22bd..6006fef9c 100644 --- a/src/conf.py +++ b/src/conf.py @@ -23,7 +23,12 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ["math_dollar"] +extensions = [ + "math_dollar", + "sphinx_copybutton", # code-block copy button + # 'sphinx.ext.mathjax', + "sphinx_rtd_dark_mode", +] # Select one of the two: if os.path.exists("use_mathjax.cfg"): @@ -251,7 +256,8 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'default' +# html_theme = 'pydata_sphinx_theme' +html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -281,6 +287,8 @@ # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] +def setup(app): + app.add_css_file("css/no_width_limit_n_autowrap_code.css") # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. From d723be69715d35eb9a7954efdfea5ad5c5d92a90 Mon Sep 17 00:00:00 2001 From: ZhengZhilin Date: Fri, 20 Oct 2023 10:11:24 +0800 Subject: [PATCH 3/7] add .gitignore to ignore _build and .pyc files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..4259313a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +_build/ +*.pyc \ No newline at end of file From ecfebe8c42a9114d0db0b94feeea8b3aec6272b5 Mon Sep 17 00:00:00 2001 From: ZhengZhilin Date: Fri, 20 Oct 2023 10:12:17 +0800 Subject: [PATCH 4/7] use rtd theme with dark mode toggle button --- ...th_limit_n_autowrap_code.css => autowrap_code.css} | 4 ---- src/_static/css/equation_style.css | 7 +++++++ src/_static/css/no_width_limit.css | 3 +++ src/conf.py | 11 ++++++----- 4 files changed, 16 insertions(+), 9 deletions(-) rename src/_static/css/{no_width_limit_n_autowrap_code.css => autowrap_code.css} (63%) create mode 100644 src/_static/css/equation_style.css create mode 100644 src/_static/css/no_width_limit.css diff --git a/src/_static/css/no_width_limit_n_autowrap_code.css b/src/_static/css/autowrap_code.css similarity index 63% rename from src/_static/css/no_width_limit_n_autowrap_code.css rename to src/_static/css/autowrap_code.css index f391fab16..7f01579c5 100644 --- a/src/_static/css/no_width_limit_n_autowrap_code.css +++ b/src/_static/css/autowrap_code.css @@ -1,7 +1,3 @@ -.wy-nav-content { - max-width: none; -} - pre { white-space: pre-wrap !important; word-break: break-all; diff --git a/src/_static/css/equation_style.css b/src/_static/css/equation_style.css new file mode 100644 index 000000000..663c9268f --- /dev/null +++ b/src/_static/css/equation_style.css @@ -0,0 +1,7 @@ +.math { + text-align: left; +} + +.eqno { + float: right; +} diff --git a/src/_static/css/no_width_limit.css b/src/_static/css/no_width_limit.css new file mode 100644 index 000000000..579fe077d --- /dev/null +++ b/src/_static/css/no_width_limit.css @@ -0,0 +1,3 @@ +.wy-nav-content { + max-width: none; +} \ No newline at end of file diff --git a/src/conf.py b/src/conf.py index 6006fef9c..39f42cfee 100644 --- a/src/conf.py +++ b/src/conf.py @@ -26,8 +26,7 @@ extensions = [ "math_dollar", "sphinx_copybutton", # code-block copy button - # 'sphinx.ext.mathjax', - "sphinx_rtd_dark_mode", + "sphinx_rtd_dark_mode", # must comment this to use pydata theme ] # Select one of the two: @@ -256,8 +255,8 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -# html_theme = 'pydata_sphinx_theme' -html_theme = 'sphinx_rtd_theme' +html_theme = 'pydata_sphinx_theme' +# html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -288,7 +287,9 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] def setup(app): - app.add_css_file("css/no_width_limit_n_autowrap_code.css") + app.add_css_file("css/autowrap_code.css") + app.add_css_file("css/no_width_limit.css") + app.add_css_file("css/equation_style.css") # uncomment this for html_mathjax when using rtd theme # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. From 718d1de13804e5f5a022383a9aef15e7580062a1 Mon Sep 17 00:00:00 2001 From: ZhengZhilin Date: Fri, 20 Oct 2023 10:18:56 +0800 Subject: [PATCH 5/7] update build prerequisites --- README.rst | 13 ++----------- environment.yml | 4 +--- requirements.txt | 3 +++ 3 files changed, 6 insertions(+), 14 deletions(-) create mode 100644 requirements.txt diff --git a/README.rst b/README.rst index b24604210..ac2904a5f 100644 --- a/README.rst +++ b/README.rst @@ -16,6 +16,7 @@ Build Install prerequisites:: sudo apt-get install texlive-fonts-recommended texlive-latex-extra texlive-fonts-extra dvipng + pip install -r requirements.txt To build the book, do:: @@ -24,17 +25,6 @@ To build the book, do:: This builds both html and pdf versions, that you can find in the _build directory. -For mac user ------------- - -prerequisites:: - -- [port](https://www.macports.org/install.php) to install dvisvgm -- [homebrew](https://brew.sh/) to install texlive -- [conda](https://www.anaconda.com/download) to install sphinx and related extensions - - - Build Using Conda ----------------- @@ -43,6 +33,7 @@ Conda build:: conda env create -f environment.yml # mamba env create -f environment.yml # only if you have mamba installed conda activate tprbook + pip install -r requirements.txt make latex tectonic _build/latex/theoretical-physics.tex diff --git a/environment.yml b/environment.yml index 7ab5dad59..6ad782c7e 100644 --- a/environment.yml +++ b/environment.yml @@ -5,6 +5,4 @@ dependencies: - python=3.10 - myst-parser=1.0.0 - sphinx=6.1.3 - - tectonic=0.12.0 - - sphinx-copybutton - - pydata-sphinx-theme \ No newline at end of file + - tectonic=0.12.0 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..373d90296 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +sphinx-copybutton +pydata-sphinx-theme +sphinx-rtd-dark-mode \ No newline at end of file From d9cd5e2e4a25fcb0df3b704133057e93a3b89eb5 Mon Sep 17 00:00:00 2001 From: ZhengZhilin Date: Fri, 20 Oct 2023 11:15:45 +0800 Subject: [PATCH 6/7] sphinx-book-theme suits better than pydata --- requirements.txt | 3 ++- src/conf.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 373d90296..444ce1701 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ sphinx-copybutton pydata-sphinx-theme -sphinx-rtd-dark-mode \ No newline at end of file +sphinx-rtd-dark-mode +sphinx-book-theme \ No newline at end of file diff --git a/src/conf.py b/src/conf.py index 39f42cfee..1d4400cf1 100644 --- a/src/conf.py +++ b/src/conf.py @@ -26,7 +26,7 @@ extensions = [ "math_dollar", "sphinx_copybutton", # code-block copy button - "sphinx_rtd_dark_mode", # must comment this to use pydata theme + # "sphinx_rtd_dark_mode", # must comment this to use pydata theme ] # Select one of the two: @@ -255,7 +255,8 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'pydata_sphinx_theme' +# html_theme = 'pydata_sphinx_theme' +html_theme = 'sphinx_book_theme' # html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme From eaf560e4028cd2d1f8d20dbdf3fb0ced578b0374 Mon Sep 17 00:00:00 2001 From: Zhilin Zheng Date: Fri, 20 Oct 2023 16:16:28 +0800 Subject: [PATCH 7/7] Update CI.yml try to install requirements before building --- .github/workflows/CI.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d3cdef0c5..ea78f88fb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -38,6 +38,11 @@ jobs: conda info conda list + - name: pip install requirements + shell : bash -l {0} + run: | + pip install -r requirements.txt + - name: Build html shell: bash -l {0} run: |