diff --git a/.gitignore b/.gitignore
index 6beb27e..68cf345 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,7 +71,9 @@ instance/
# Sphinx documentation
docs/build/
+docs/_build/
docs/source/tutorials/*.ipynb
+docs/source/tutorials/
# PyBuilder
.pybuilder/
@@ -173,7 +175,6 @@ cython_debug/
# Unit test output
junit/
-
# LaTeX files
*.aux
*.pdf
diff --git a/docs/source/api.md b/docs/source/api.md
new file mode 100644
index 0000000..a1c08b6
--- /dev/null
+++ b/docs/source/api.md
@@ -0,0 +1,6 @@
+# API
+
+Description of the API
+
+```{toctree}
+:maxdepth: 1
\ No newline at end of file
diff --git a/docs/source/conf.py b/docs/source/conf.py
index b1fada9..7e06359 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -6,6 +6,9 @@
import os
import shutil
+# At the top.
+import sphinx_bootstrap_theme
+
def copy_tutorials(app):
src = os.path.abspath("../tutorials")
@@ -20,6 +23,8 @@ def copy_tutorials(app):
def setup(app):
app.connect("builder-inited", copy_tutorials)
+ # app.add_stylesheet("my-styles.css")
+ app.add_css_file("custom.css")
# -- Project information -----------------------------------------------------
@@ -36,14 +41,97 @@ def setup(app):
"nbsphinx",
"sphinx.ext.mathjax",
"sphinx.ext.autodoc",
+ "myst_parser", # enable Markdown support
]
-templates_path = ["_templates"]
exclude_patterns = []
+# Recognize both .rst and .md
+source_suffix = {
+ ".rst": "restructuredtext",
+ ".md": "markdown",
+}
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
-html_theme = "sphinx_rtd_theme"
+# html_theme = "furo"
+# conf.py
+# ...
+
+# Activate the theme.
+html_theme = "bootstrap"
+html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
+
+# (Optional) Logo. Should be small enough to fit the navbar (ideally 24x24).
+# Path should be relative to the ``_static`` files directory.
+# html_logo = "my_logo.png"
+
+# Theme options are theme-specific and customize the look and feel of a
+# theme further.
+html_theme_options = {
+ # Navigation bar title. (Default: ``project`` value)
+ "navbar_title": "python-template",
+ # Tab name for entire site. (Default: "Site")
+ "navbar_site_name": "Site",
+ # A list of tuples containing pages or urls to link to.
+ # Valid tuples should be in the following forms:
+ # (name, page) # a link to a page
+ # (name, "/aa/bb", 1) # a link to an arbitrary relative url
+ # (name, "http://example.com", True) # arbitrary absolute url
+ # Note the "1" or "True" value above as the third argument to indicate
+ # an arbitrary url.
+ "navbar_links": [
+ ("Quickstart", "quickstart"),
+ ("Tutorials", "tutorials"),
+ ("API", "api"),
+ # ("Link", "http://example.com", True),
+ ],
+ # Render the next and previous page links in navbar. (Default: true)
+ "navbar_sidebarrel": False,
+ # Render the current pages TOC in the navbar. (Default: true)
+ "navbar_pagenav": False,
+ # Tab name for the current pages TOC. (Default: "Page")
+ "navbar_pagenav_name": "Page",
+ # Global TOC depth for "site" navbar tab. (Default: 1)
+ # Switching to -1 shows all levels.
+ "globaltoc_depth": 2,
+ # Include hidden TOCs in Site navbar?
+ #
+ # Note: If this is "false", you cannot have mixed ``:hidden:`` and
+ # non-hidden ``toctree`` directives in the same page, or else the build
+ # will break.
+ #
+ # Values: "true" (default) or "false"
+ "globaltoc_includehidden": "true",
+ # HTML navbar class (Default: "navbar") to attach to
element.
+ # For black navbar, do "navbar navbar-inverse"
+ "navbar_class": "navbar inverse",
+ # Fix navigation bar to top of page?
+ # Values: "true" (default) or "false"
+ "navbar_fixed_top": "true",
+ # Location of link to source.
+ # Options are "nav" (default), "footer" or anything else to exclude.
+ "source_link_position": "footer",
+ # Bootswatch (http://bootswatch.com/) theme.
+ #
+ # Options are nothing (default) or the name of a valid theme
+ # such as "cosmo" or "sandstone".
+ #
+ # The set of valid themes depend on the version of Bootstrap
+ # that's used (the next config option).
+ #
+ # Currently, the supported themes are:
+ # - Bootstrap 2: https://bootswatch.com/2
+ # - Bootstrap 3: https://bootswatch.com/3
+ "bootswatch_theme": "flatly",
+ # Choose Bootstrap version.
+ # Values: "3" (default) or "2" (in quotes)
+ "bootstrap_version": "3",
+}
+
html_static_path = ["_static"]
+templates_path = ["_templates"]
+
+
+html_sidebars = {"**": []}
diff --git a/docs/source/index.md b/docs/source/index.md
new file mode 100644
index 0000000..d082474
--- /dev/null
+++ b/docs/source/index.md
@@ -0,0 +1,11 @@
+# Welcome
+
+Write the documentation of your python package here
+
+```{toctree}
+:maxdepth: 2
+:caption: Contents
+
+quickstart.md
+tutorials.md
+api.md
diff --git a/docs/source/index.rst b/docs/source/index.rst
deleted file mode 100644
index f7fbdd2..0000000
--- a/docs/source/index.rst
+++ /dev/null
@@ -1,16 +0,0 @@
-.. Documentation master file, created by
- sphinx-quickstart on Sun Jun 22 11:14:00 2025.
- You can adapt this file completely to your liking, but it should at least
- contain the root `toctree` directive.
-
-maxtikzlib
-=============================
-
-Here are a few tutorials to help you get started with `maxtikzlib`
-
-.. toctree::
- :maxdepth: 2
- :caption: Tutorials:
- :glob:
-
- tutorials/*
diff --git a/docs/source/quickstart.md b/docs/source/quickstart.md
new file mode 100644
index 0000000..d8e6e56
--- /dev/null
+++ b/docs/source/quickstart.md
@@ -0,0 +1,32 @@
+# Quickstart
+
+Clone the repo
+
+```
+git clone ...
+```
+
+Create and activate python environment
+
+```
+python -m venv env
+source env/bin/activate
+pip install --upgrade pip
+```
+
+Install the code and requirements with pip
+
+```
+pip install -e .
+```
+
+# Build docs
+
+```
+make html
+cd ../
+open docs/_build/html/index.html
+```
+
+```{toctree}
+:maxdepth: 1
\ No newline at end of file
diff --git a/docs/source/tutorials.md b/docs/source/tutorials.md
new file mode 100644
index 0000000..84e10de
--- /dev/null
+++ b/docs/source/tutorials.md
@@ -0,0 +1,9 @@
+# Tutorials
+
+Here are a few tutorials to help you get started.
+
+```{toctree}
+:maxdepth: 1
+:glob:
+
+tutorials/*
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 3cdbc4c..bdf3960 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -40,7 +40,7 @@ docs = [
"pre-commit",
"pyproject-fmt",
"sphinx",
- "sphinx-rtd-theme",
+ "sphinx_bootstrap_theme",
"scipy",
]
diff --git a/src/maxtikzlib/figure.py b/src/maxtikzlib/figure.py
index 0268780..5bab24f 100644
--- a/src/maxtikzlib/figure.py
+++ b/src/maxtikzlib/figure.py
@@ -18,7 +18,7 @@
class TikzFigure:
- def __init__(self, **kwargs):
+ def __init__(self, ndim=2, **kwargs):
"""
Initialize the TikzFigure class for creating TikZ figures.
@@ -44,6 +44,7 @@ def __init__(self, **kwargs):
self.nodes = []
self.paths = []
self.layers = {}
+ self._ndim = ndim
# Counter for unnamed nodes
self._node_counter = 0
@@ -369,14 +370,15 @@ def generate_tikz(self):
- tikz_script (str): The TikZ script as a string.
"""
tikz_script = "\\begin{tikzpicture}\n"
- tikz_script += "\\begin{axis}[\n"
- tikz_script += "view={20}{30},\n"
- tikz_script += "axis lines=center,\n"
- tikz_script += "xlabel={$x$},\n"
- tikz_script += "ylabel={$y$},\n"
- tikz_script += "zlabel={$z$},\n"
- tikz_script += "grid=major\n"
- tikz_script += " ]\n"
+ if self.ndim == 3:
+ tikz_script += "\\begin{axis}[\n"
+ tikz_script += "view={20}{30},\n"
+ tikz_script += "axis lines=center,\n"
+ tikz_script += "xlabel={$x$},\n"
+ tikz_script += "ylabel={$y$},\n"
+ tikz_script += "zlabel={$z$},\n"
+ tikz_script += "grid=major\n"
+ tikz_script += " ]\n"
if self._figure_setup:
tikz_script += f"[{self._figure_setup}]"
@@ -422,7 +424,8 @@ def generate_tikz(self):
for layer in ordered_layers:
tikz_script += layer.generate_tikz()
- tikz_script += "\\end{axis}\n"
+ if self.ndim == 3:
+ tikz_script += "\\end{axis}\n"
tikz_script += "\\end{tikzpicture}"
# Wrap in figure environment if necessary
@@ -675,6 +678,10 @@ def plot_matplotlib(self, ax):
ax.set_ylim(min(all_y) - padding, max(all_y) + padding)
ax.set_aspect("equal", adjustable="datalim")
+ @property
+ def ndim(self):
+ return self._ndim
+
# class TikzFigure3D
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tutorials/tutorial_01.ipynb b/tutorials/tutorial_01.ipynb
index b6aa47f..364980a 100644
--- a/tutorials/tutorial_01.ipynb
+++ b/tutorials/tutorial_01.ipynb
@@ -234,7 +234,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3 (ipykernel)",
+ "display_name": "env_maxtikzlib",
"language": "python",
"name": "python3"
},
@@ -248,7 +248,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.3"
+ "version": "3.13.3"
}
},
"nbformat": 4,
diff --git a/tutorials/tutorial_05.ipynb b/tutorials/tutorial_05.ipynb
index 8a27335..2758cf7 100644
--- a/tutorials/tutorial_05.ipynb
+++ b/tutorials/tutorial_05.ipynb
@@ -70,7 +70,7 @@
"zvec = states[:, 2]\n",
"\n",
"# Plot the lorenz system\n",
- "fig = TikzFigure()\n",
+ "fig = TikzFigure(ndim=3)\n",
"options = [\"color=black\", \"thick\"]\n",
"\n",
"fig.add_plot3d(xvec, yvec, zvec, options=options, layer=0)\n",
@@ -117,7 +117,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.12"
+ "version": "3.13.3"
}
},
"nbformat": 4,