Skip to content

Commit 44308a8

Browse files
committed
update for JOSS
JOSS Intro Tutorial Fix - update line lengths (to 79) in tutorials - edit intro tutorial per JOSS requests - edit visualization tutorial per JOSS request - update pyproject.toml to autofix code cell lengths - remove pyprojoect.toml spurious assumption about it being taken care of black formatting - add .virtual documents to .gitignore - test_agent was reformatted due to pyproject.toml changes - remove upper left version switcher - update email in pyproject.toml
1 parent 033facc commit 44308a8

6 files changed

+282
-407
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ target/
6969

7070
# Jupyter and iPython notebook checkpoints
7171
*.ipynb_checkpoints
72+
*.virtual_documents
7273

7374
# Spyder app workspace config file
7475
.spyderworkspace

docs/conf.py

+44-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# noqa: D100
21
#!/usr/bin/env python3
32
#
43
# Mesa documentation build configuration file, created by
@@ -16,8 +15,8 @@
1615
import os
1716
import os.path as osp
1817
import pathlib
19-
import sys
2018
import string
19+
import sys
2120
from datetime import date
2221

2322
# If extensions (or modules to document with autodoc) are in another directory,
@@ -47,7 +46,7 @@
4746
"sphinx.ext.viewcode",
4847
"sphinx.ext.napoleon", # for google style docstrings
4948
"myst_nb", # For Markdown and Jupyter notebooks
50-
"sphinx_copybutton" # For copying the code in the documentation
49+
"sphinx_copybutton", # For copying the code in the documentation
5150
]
5251

5352
# Add any paths that contain templates here, relative to this directory.
@@ -131,11 +130,7 @@
131130
# further. For a list of options available for each theme, see the
132131
# documentation.
133132
html_theme_options = {
134-
"navbar_start": ["navbar-logo", "version-switcher"], # Show switcher in navbar
135-
"switcher": {
136-
"json_url": "https://mesa.readthedocs.io/latest/_static/switcher.json", # URL of your switcher.json file
137-
"version_match": version # Automatically matches the current version
138-
}
133+
"navbar_start": ["navbar-logo"],
139134
}
140135

141136
# Add any paths that contain custom themes here, relative to this directory.
@@ -177,7 +172,7 @@
177172

178173
# Custom sidebar templates, maps document names to template names.
179174
html_sidebars = {
180-
'migration_guide': [], # No sidebar migration
175+
"migration_guide": [], # No sidebar migration
181176
}
182177

183178
# Additional templates that should be rendered to pages, maps page names to
@@ -297,8 +292,9 @@
297292
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
298293

299294

300-
301-
def write_example_md_file(agent_filename, model_filename, readme_filename, app_filename, md_filepath, template):
295+
def write_example_md_file(
296+
agent_filename, model_filename, readme_filename, app_filename, md_filepath, template
297+
):
302298
with open(agent_filename) as content_file:
303299
agent_file = content_file.read()
304300
with open(model_filename) as content_file:
@@ -310,17 +306,30 @@ def write_example_md_file(agent_filename, model_filename, readme_filename, app_f
310306

311307
with open(md_filepath, "w") as fh:
312308
content = template.substitute(
313-
dict(agent_file=agent_file, model_file=model_file,
314-
readme_file=readme_file, app_file=app_file)
309+
dict(
310+
agent_file=agent_file,
311+
model_file=model_file,
312+
readme_file=readme_file,
313+
app_file=app_file,
314+
)
315315
)
316316
fh.write(content)
317317

318+
318319
def setup_examples_pages():
319320
# create md files for all examples
320321
# check what examples exist
321322
examples_folder = osp.abspath(osp.join(HERE, "..", "mesa", "examples"))
322-
basic_examples = [("basic", f.path) for f in os.scandir(osp.join(examples_folder, "basic")) if f.is_dir() and not f.name.startswith("__") ]
323-
advanced_examples = [("advanced", f.path) for f in os.scandir(osp.join(examples_folder, "advanced")) if f.is_dir() and not f.name.startswith("__")]
323+
basic_examples = [
324+
("basic", f.path)
325+
for f in os.scandir(osp.join(examples_folder, "basic"))
326+
if f.is_dir() and not f.name.startswith("__")
327+
]
328+
advanced_examples = [
329+
("advanced", f.path)
330+
for f in os.scandir(osp.join(examples_folder, "advanced"))
331+
if f.is_dir() and not f.name.startswith("__")
332+
]
324333
examples = basic_examples + advanced_examples
325334

326335
with open(os.path.join(HERE, "example_template.txt")) as fh:
@@ -329,7 +338,9 @@ def setup_examples_pages():
329338
root_folder = pathlib.Path(os.path.join(HERE, "examples"))
330339
root_folder.mkdir(parents=True, exist_ok=True)
331340
pathlib.Path(os.path.join(root_folder, "basic")).mkdir(parents=True, exist_ok=True)
332-
pathlib.Path(os.path.join(root_folder, "advanced")).mkdir(parents=True, exist_ok=True)
341+
pathlib.Path(os.path.join(root_folder, "advanced")).mkdir(
342+
parents=True, exist_ok=True
343+
)
333344

334345
examples_md = []
335346
for kind, example in examples:
@@ -344,7 +355,14 @@ def setup_examples_pages():
344355
examples_md.append((base_name, f"{kind}/{base_name}"))
345356

346357
md_filepath = os.path.join(HERE, "examples", kind, md_filename)
347-
write_example_md_file(agent_filename, model_filename, readme_filename, app_filename, md_filepath, template)
358+
write_example_md_file(
359+
agent_filename,
360+
model_filename,
361+
readme_filename,
362+
app_filename,
363+
md_filepath,
364+
template,
365+
)
348366

349367
# create overview of examples.md
350368
with open(os.path.join(HERE, "examples_overview_template.txt")) as fh:
@@ -357,14 +375,21 @@ def setup_examples_pages():
357375
content = template.substitute(
358376
dict(
359377
readme=readme_md,
360-
example_paths="\n".join([f"{' '.join(a.split('_'))} </examples/{b}>" for a, b in examples_md]),
378+
example_paths="\n".join(
379+
[
380+
f"{' '.join(a.split('_'))} </examples/{b}>"
381+
for a, b in examples_md
382+
]
383+
),
361384
)
362385
)
363386
fh.write(content)
364387

388+
365389
def setup(app):
366390
setup_examples_pages()
367391

392+
368393
#
369394
if __name__ == "__main__":
370-
setup_examples_pages()
395+
setup_examples_pages()

docs/tutorials/MoneyModel.py

-81
This file was deleted.

0 commit comments

Comments
 (0)