Skip to content

Commit cb191ca

Browse files
docs: add admonitions to the example page
1 parent a3de455 commit cb191ca

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

doc/source/conf.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"sphinx_design",
7878
"sphinx_jinja",
7979
"sphinx_gallery.gen_gallery",
80+
"sphinx.ext.todo",
8081
]
8182

8283
# Intersphinx mapping
@@ -180,7 +181,7 @@
180181

181182

182183
def extract_example_links(
183-
repo_fullname: str, path_relative_to_root: str, exclude_files: List[str]
184+
repo_fullname: str, path_relative_to_root: str, exclude_files: List[str] = []
184185
) -> List[str]:
185186
"""
186187
Extract example links from a specific GitHub repository.
@@ -202,7 +203,8 @@ def extract_example_links(
202203
g = Github()
203204
repo = g.get_repo(repo_fullname)
204205
contents = repo.get_contents(path_relative_to_root)
205-
206+
if not isinstance(contents, list):
207+
contents = [contents]
206208
example_links = []
207209
for content in contents:
208210
if content.type == "dir":
@@ -252,8 +254,17 @@ def download_and_process_files(example_links: List[str]) -> List[str]:
252254
)
253255
file_names = download_and_process_files(example_links)
254256

257+
admonitions_links = extract_example_links(
258+
"pydata/pydata-sphinx-theme",
259+
"docs/examples/kitchen-sink/admonitions.rst",
260+
)
261+
262+
admonitions_links = download_and_process_files(admonitions_links)
263+
print(admonitions_links)
264+
255265
jinja_contexts = {
256266
"examples": {"inputs_examples": file_names},
267+
"admonitions": {"inputs_admonitions": admonitions_links},
257268
"install_guide": {
258269
"version": f"v{version}" if not version.endswith("dev0") else "main",
259270
},

doc/source/examples.rst

+7
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ extensions are rendered in the theme.
2828

2929
Examples of sphinx gallery rendered using the `ansys-sphinx-theme`.
3030

31+
.. grid-item-card:: Admonitions
32+
:link: admonitions
33+
:link-type: ref
34+
35+
Examples of admonitions rendered using the `ansys-sphinx-theme`.
36+
3137

3238
.. toctree::
3339
:hidden:
3440
:maxdepth: 2
3541

3642
examples/sphinx-design
3743
examples/table
44+
examples/admonitions
3845

doc/source/examples/admonitions.rst

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. _admonitions:
2+
3+
Admonitions
4+
===========
5+
6+
Admonitions are a way to highlight important information in your documentation. They are a way to draw attention to important information,
7+
and can be used to provide additional context or information to the reader.
8+
9+
This page shows how the admonitions are rendered in the documentation with ansys sphinx theme.
10+
11+
Credits and acknowledgments
12+
---------------------------
13+
The examples shown below is downloaded from the pydata sphinx theme project.
14+
The original page can be found at `Pydata sphinx theme <https://pydata-sphinx-theme.readthedocs.io/en/stable/examples/kitchen-sink/index.html>`_ .
15+
16+
17+
.. jinja:: admonitions
18+
19+
{% for filename in inputs_admonitions %}
20+
21+
.. include:: sphinx_examples/{{ filename }}
22+
23+
{% endfor %}

0 commit comments

Comments
 (0)