Skip to content

Commit effde90

Browse files
Transition to Pydata Sphinx Theme (#482)
* add pydata theme dependencies add some organization of current files to filt #362 add reference remove jupyter-lite and jupyter-sphinx deps, update python docs to references/python refactor docs to fit new top level architecture of user guide, contribution, packages and references add sample switcher json add skeleton for version switcher add pointer to note on versioning Update python/packages/autogen-core/docs/src/_static/switcher.json Co-authored-by: Jack Gerrits <[email protected]> Update python/packages/autogen-core/docs/src/_static/switcher.json Co-authored-by: Jack Gerrits <[email protected]> remove unused components add privacy footer hide previous and next button remove 'Section Navigation' from sidebar make packages a single page general refactor, add missing items remove unneeded sidebar conf remove duplicate content on landing page update landing page text. general refactor, remove unreferences files, fix some build errors * remove extra files * move readme to correct location * remove sidebar from packages page, layout updates * update lock and add clean command * remove discord --------- Co-authored-by: Jack Gerrits <[email protected]> Co-authored-by: Jack Gerrits <[email protected]>
1 parent 2dcb1f4 commit effde90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+618
-88
lines changed

python/packages/autogen-core/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ cython_debug/
161161

162162
.ruff_cache/
163163

164-
/docs/src/reference
164+
/docs/src/reference/python
165165
.DS_Store
166166

167167
# Generated log files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Building the AGNext Documentation
2+
3+
AGNext documentation is based on the sphinx documentation system and uses the myst-parser to render markdown files. It uses the [pydata-sphinx-theme](https://pydata-sphinx-theme.readthedocs.io/en/latest/) to style the documentation.
4+
5+
### Prerequisites
6+
7+
Ensure you have all of the dev dependencies for the `autogen-core` package installed. You can install them by running the following command from the root of the python repository:
8+
9+
```bash
10+
uv sync
11+
source .venv/bin/activate
12+
```
13+
14+
## Building Docs
15+
16+
To build the documentation, run the following command from the root of the python repository:
17+
18+
```bash
19+
poe --directory ./packages/autogen-core/ docs-build
20+
```
21+
22+
To serve the documentation locally, run the following command from the root of the python repository:
23+
24+
```bash
25+
poe --directory ./packages/autogen-core/ docs-serve
26+
```
27+
28+
[!NOTE]
29+
Sphinx will only rebuild files that have changed since the last build. If you want to force a full rebuild, you can delete the `./packages/autogen-core/docs/build` directory before running the `docs-build` command.
30+
31+
## Versioning the Documentation
32+
33+
The current theme - [pydata-sphinx-theme](https://pydata-sphinx-theme.readthedocs.io/en/latest/) - supports [switching between versions](https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/version-dropdown.html) of the documentation.
34+
35+
To version the documentation, you need to create a new version of the documentation by copying the existing documentation to a new directory with the version number. For example, to create a new version of the documentation for version `0.1.0`, you would run the following command:
36+
37+
How are various versions built? - TBD.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.bd-links__title {
2+
display: none;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"name": "v0.2 (stable)",
4+
"version": "0.2",
5+
"url": "https://microsoft.github.io/autogen/en/0.2/"
6+
},
7+
{
8+
"version": "dev",
9+
"url": "https://microsoft.github.io/autogen/en/dev/"
10+
}
11+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% if sourcename is defined and theme_use_edit_page_button and page_source_suffix %}
2+
{% set src = sourcename.split('.') %}
3+
<div class="tocsection editthispage">
4+
<a href="{{ to_main(get_edit_provider_and_url()[1]) }}">
5+
<i class="fa-solid fa-pencil"></i>
6+
{% set provider = get_edit_provider_and_url()[0] %}
7+
{% block edit_this_page_text %}
8+
{% if provider %}
9+
{% trans provider=provider %}Edit on {{ provider }}{% endtrans %}
10+
{% else %}
11+
{% trans %}Edit{% endtrans %}
12+
{% endif %}
13+
{% endblock %}
14+
</a>
15+
</div>
16+
{% endif %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{% extends "!layout.html" %}
2+
3+
{% block footer %}
4+
<footer class="bd-footer">
5+
<div class="container">
6+
<div class="row">
7+
<div class="col-12 col-md-4 mb-4 mb-md-0">
8+
<h6>About</h5>
9+
<p>&copy; 2024 Microsoft.</p>
10+
</div>
11+
<div class="col-6 col-md-4 mb-4 mb-md-0">
12+
<h6>Links</h5>
13+
<ul class="list-unstyled">
14+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=521839">Privacy Policy</a> | <a href="https://go.microsoft.com/fwlink/?linkid=2259814">Consumer Health Privacy</a> </li>
15+
16+
</ul>
17+
</div>
18+
<div class="col-6 col-md-4">
19+
<h6>Community</h5>
20+
<ul class="list-unstyled">
21+
<li>
22+
<a href="https://x.com/pyautogen" target="_blank">Twitter</a>
23+
</li>
24+
</ul>
25+
</div>
26+
</div>
27+
</div>
28+
</footer>
29+
{% endblock %}
30+

0 commit comments

Comments
 (0)