Skip to content

Commit 9da27b8

Browse files
committed
Update home page and overall organization
1 parent 8181c6c commit 9da27b8

26 files changed

+594
-97
lines changed

Diff for: source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"pyscfdocext",
3030
"myst_parser",
3131
"sphinx_design",
32-
# "gallery_directive",
32+
"gallery_directive",
3333
]
3434
bibtex_bibfiles = ['user/ref.bib']
3535
myst_update_mathjax = False
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: source/contributor/index.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributor Guide
2+
3+
A more complete Contributor Guide for PySCF is planned for the future.
4+
5+
```{toctree}
6+
:caption: Style guide
7+
:maxdepth: 1
8+
9+
code-standard
10+
```
11+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: source/index.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
html_theme.sidebar_secondary.remove: true
3+
---
4+
5+
# Quantum chemistry with Python
6+
7+
8+
```{gallery-grid}
9+
:grid-columns: 1 2 2 3
10+
11+
- header: "{fab}`python;pst-color-primary` Primarily Python"
12+
content: "Easy to read and write, for quick development with fewer mistakes."
13+
- header: "{fas}`bolt;pst-color-primary` Fast"
14+
content: "Uses NumPy, SciPy, and custom C/C++ code."
15+
- header: "{fa}`code-branch;pst-color-primary` Free and open-source"
16+
content: "Accessible and community-driven. Distributed on [GitHub](https://github.com/pyscf/pyscf) under the [Apache-2.0](https://github.com/pyscf/pyscf/tree/master?tab=Apache-2.0-1-ov-file#readme) license."
17+
- header: "{fas}`gears;pst-color-primary` Modular"
18+
content: "Easily integrated into complex workflows or other software packages."
19+
- header: "{fa}`list-ul;pst-color-primary` Comprehensive"
20+
content: "Extensive collection of electronic structure methods, for molecules and periodic solids."
21+
- header: "{fas}`lightbulb;pst-color-primary` Extensible"
22+
content: "See the list of [Extensions](user/extensions) to PySCF."
23+
```
24+
25+
<!---
26+
The Python-based Simulations of Chemistry Framework (PySCF) is an open-source
27+
collection of electronic structure modules powered by Python. The package
28+
provides a simple, lightweight, and efficient platform for quantum chemistry
29+
calculations and methodology development.
30+
PySCF can be used to simulate the properties of molecules, crystals, and
31+
custom Hamiltonians using mean-field and post-mean-field methods.
32+
To ensure ease of extensibility, almost all of the features in PySCF are
33+
implemented in Python, while computationally critical parts are
34+
implemented and optimized in C. Using this combined Python/C
35+
implementation, the package is as efficient as the best existing C or Fortran
36+
based quantum chemistry programs.
37+
In addition to its core libraries, PySCF supports a rich
38+
ecosystem of :ref:`installing_extproj`.
39+
--->
40+
41+
42+
```{toctree}
43+
:hidden:
44+
45+
quickstart
46+
user/index
47+
contributor/index
48+
About <about>
49+
```

Diff for: source/index.rst

-58
This file was deleted.

Diff for: source/tools/extensions/gallery_directive.py

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
"""A directive to generate a gallery of images from structured data.
2+
3+
Generating a gallery of images that are all the same size is a common
4+
pattern in documentation, and this can be cumbersome if the gallery is
5+
generated programmatically. This directive wraps this particular use-case
6+
in a helper-directive to generate it with a single YAML configuration file.
7+
8+
It currently exists for maintainers of the pydata-sphinx-theme,
9+
but might be abstracted into a standalone package if it proves useful.
10+
"""
11+
12+
from pathlib import Path
13+
from typing import Any, ClassVar, Dict, List
14+
15+
from docutils import nodes
16+
from docutils.parsers.rst import directives
17+
from sphinx.application import Sphinx
18+
from sphinx.util import logging
19+
from sphinx.util.docutils import SphinxDirective
20+
from yaml import safe_load
21+
22+
logger = logging.getLogger(__name__)
23+
24+
25+
TEMPLATE_GRID = """
26+
`````{{grid}} {columns}
27+
{options}
28+
29+
{content}
30+
31+
`````
32+
"""
33+
34+
GRID_CARD = """
35+
````{{grid-item-card}} {title}
36+
{options}
37+
38+
{content}
39+
````
40+
"""
41+
42+
43+
class GalleryGridDirective(SphinxDirective):
44+
"""A directive to show a gallery of images and links in a Bootstrap grid.
45+
46+
The grid can be generated from a YAML file that contains a list of items, or
47+
from the content of the directive (also formatted in YAML). Use the parameter
48+
"class-card" to add an additional CSS class to all cards. When specifying the grid
49+
items, you can use all parameters from "grid-item-card" directive to customize
50+
individual cards + ["image", "header", "content", "title"].
51+
52+
Danger:
53+
This directive can only be used in the context of a Myst documentation page as
54+
the templates use Markdown flavored formatting.
55+
"""
56+
57+
name = "gallery-grid"
58+
has_content = True
59+
required_arguments = 0
60+
optional_arguments = 1
61+
final_argument_whitespace = True
62+
option_spec: ClassVar[dict[str, Any]] = {
63+
# A class to be added to the resulting container
64+
"grid-columns": directives.unchanged,
65+
"class-container": directives.unchanged,
66+
"class-card": directives.unchanged,
67+
}
68+
69+
def run(self) -> List[nodes.Node]:
70+
"""Create the gallery grid."""
71+
if self.arguments:
72+
# If an argument is given, assume it's a path to a YAML file
73+
# Parse it and load it into the directive content
74+
path_data_rel = Path(self.arguments[0])
75+
path_doc, _ = self.get_source_info()
76+
path_doc = Path(path_doc).parent
77+
path_data = (path_doc / path_data_rel).resolve()
78+
if not path_data.exists():
79+
logger.info(f"Could not find grid data at {path_data}.")
80+
nodes.text("No grid data found at {path_data}.")
81+
return
82+
yaml_string = path_data.read_text()
83+
else:
84+
yaml_string = "\n".join(self.content)
85+
86+
# Use all the element with an img-bottom key as sites to show
87+
# and generate a card item for each of them
88+
grid_items = []
89+
for item in safe_load(yaml_string):
90+
# remove parameters that are not needed for the card options
91+
title = item.pop("title", "")
92+
93+
# build the content of the card using some extra parameters
94+
header = f"{item.pop('header')} \n^^^ \n" if "header" in item else ""
95+
image = f"![image]({item.pop('image')}) \n" if "image" in item else ""
96+
content = f"{item.pop('content')} \n" if "content" in item else ""
97+
98+
# optional parameter that influence all cards
99+
if "class-card" in self.options:
100+
item["class-card"] = self.options["class-card"]
101+
102+
loc_options_str = "\n".join(f":{k}: {v}" for k, v in item.items()) + " \n"
103+
104+
card = GRID_CARD.format(
105+
options=loc_options_str, content=header + image + content, title=title
106+
)
107+
grid_items.append(card)
108+
109+
# Parse the template with Sphinx Design to create an output container
110+
# Prep the options for the template grid
111+
class_ = "gallery-directive" + f' {self.options.get("class-container", "")}'
112+
options = {"gutter": 2, "class-container": class_}
113+
options_str = "\n".join(f":{k}: {v}" for k, v in options.items())
114+
115+
# Create the directive string for the grid
116+
grid_directive = TEMPLATE_GRID.format(
117+
columns=self.options.get("grid-columns", "1 2 3 4"),
118+
options=options_str,
119+
content="\n".join(grid_items),
120+
)
121+
122+
# Parse content as a directive so Sphinx Design processes it
123+
container = nodes.container()
124+
self.state.nested_parse([grid_directive], 0, container)
125+
126+
# Sphinx Design outputs a container too, so just use that
127+
return [container.children[0]]
128+
129+
130+
def setup(app: Sphinx) -> Dict[str, Any]:
131+
"""Add custom configuration to sphinx app.
132+
133+
Args:
134+
app: the Sphinx application
135+
136+
Returns:
137+
the 2 parallel parameters set to ``True``.
138+
"""
139+
app.add_directive("gallery-grid", GalleryGridDirective)
140+
141+
return {
142+
"parallel_read_safe": True,
143+
"parallel_write_safe": True,
144+
}
145+

Diff for: source/user.rst

-38
This file was deleted.

0 commit comments

Comments
 (0)