Skip to content

DOC [PST] refactor API structure and improve display #28428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dfebaa1
try to refactor api pages
Charlie-XIAO Feb 14, 2024
2b8c578
templates and better sidebar
Charlie-XIAO Feb 15, 2024
24e7d87
simplify api reference structure by making the template more flexible
Charlie-XIAO Feb 15, 2024
240d55a
[doc build] style nit
Charlie-XIAO Feb 15, 2024
199f4ad
[doc build] remove out-of-date comment
Charlie-XIAO Feb 15, 2024
ec4a781
Merge remote-tracking branch 'upstream/new_web_theme' into pst-api
Charlie-XIAO Feb 15, 2024
b141d67
[doc build] trigger full build
Charlie-XIAO Feb 15, 2024
c2f106b
Merge remote-tracking branch 'upstream/new_web_theme' into pst-api
Charlie-XIAO Feb 16, 2024
df1b473
add search table on api index page
Charlie-XIAO Feb 17, 2024
f9027e8
[doc build] trigger full build
Charlie-XIAO Feb 17, 2024
bcb014e
[doc build] fix for deprecated api
Charlie-XIAO Feb 17, 2024
9b7fccb
[doc build] remove testing code
Charlie-XIAO Feb 17, 2024
b475363
Merge remote-tracking branch 'upstream/new_web_theme' into pst-api
Charlie-XIAO Feb 23, 2024
c05d875
[doc build] show all api on index page by default
Charlie-XIAO Feb 23, 2024
4e61daf
[doc build] use templates; refactor api search table
Charlie-XIAO Feb 24, 2024
0b303af
[doc build] revert to showing all by default; deprecation badge style
Charlie-XIAO Feb 24, 2024
2073910
[doc build] finer level of current module
Charlie-XIAO Feb 24, 2024
8ffcc34
[doc build] secondary sidebar removal also for module pages
Charlie-XIAO Feb 25, 2024
720cbe6
[doc build] do not hide deprecated from toctree
Charlie-XIAO Feb 25, 2024
92f870d
[doc build] fix make.bat typo
Charlie-XIAO Feb 25, 2024
61f5d1a
[doc build] docstrings comply to PEP257
Charlie-XIAO Feb 27, 2024
1690722
Merge remote-tracking branch 'upstream/new_web_theme' into pst-api
Charlie-XIAO Feb 27, 2024
d0300fe
[doc build] docstrings comply to PEP257 for utils subpackages
Charlie-XIAO Feb 27, 2024
b10343b
Merge remote-tracking branch 'upstream/new_web_theme' into pst-api
Charlie-XIAO Feb 27, 2024
0a0fc02
fix comments
Charlie-XIAO Feb 27, 2024
e6c7029
fix broken toctree structure
Charlie-XIAO Feb 29, 2024
32e7d06
[doc build] trigger full build
Charlie-XIAO Feb 29, 2024
48a485a
Merge remote-tracking branch 'upstream/new_web_theme' into pst-api
Charlie-XIAO Mar 11, 2024
9e94b38
[doc build] move api_reference helper script to under doc/
Charlie-XIAO Mar 14, 2024
aabb81d
Merge remote-tracking branch 'upstream/new_web_theme' into pst-api
Charlie-XIAO Mar 14, 2024
c55a90c
[doc build] trigger full doc build
Charlie-XIAO Mar 14, 2024
1aa8ffa
[doc build] remove unnecessary codecov ignore
Charlie-XIAO Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dist/
MANIFEST
doc/sg_execution_times.rst
doc/_build/
doc/api/*.rst
doc/auto_examples/
doc/css/*
!doc/css/.gitkeep
Expand Down
2 changes: 1 addition & 1 deletion build_tools/circle/build_doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ then
(
echo '<html><body><ul>'
echo "$affected" | sed 's|.*|<li><a href="&">&</a> [<a href="https://scikit-learn.org/dev/&">dev</a>, <a href="https://scikit-learn.org/stable/&">stable</a>]</li>|'
echo '</ul><p>General: <a href="index.html">Home</a> | <a href="modules/classes.html">API Reference</a> | <a href="auto_examples/index.html">Examples</a></p>'
echo '</ul><p>General: <a href="index.html">Home</a> | <a href="api/index.html">API Reference</a> | <a href="auto_examples/index.html">Examples</a></p>'
echo '<strong>Sphinx Warnings in affected files</strong><ul>'
echo "$warnings" | sed 's/\/home\/circleci\/project\//<li>/g'
echo '</ul></body></html>'
Expand Down
1 change: 1 addition & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ clean:
-rm -rf generated/*
-rm -rf modules/generated/
-rm -rf css/styles/
-rm -rf api/*.rst

# Default to SPHINX_NUMJOBS=1 for full documentation build. Using
# SPHINX_NUMJOBS!=1 may actually slow down the build, or cause weird issues in
Expand Down
24 changes: 24 additions & 0 deletions doc/api/deprecated.rst.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
:html_theme.sidebar_secondary.remove:

.. _api_depr_ref:

Recently Deprecated
===================

.. currentmodule:: sklearn

{% for ver, objs in DEPRECATED_API_REFERENCE %}
.. _api_depr_ref-{{ ver|replace(".", "-") }}:

.. rubric:: To be removed in {{ ver }}

.. autosummary::
:nosignatures:
:toctree: ../modules/generated/
:template: base.rst

{% for obj in objs %}
{{ obj }}
{%- endfor %}

{% endfor %}
77 changes: 77 additions & 0 deletions doc/api/index.rst.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
:html_theme.sidebar_secondary.remove:

.. _api_ref:

=============
API Reference
=============

This is the class and function reference of scikit-learn. Please refer to the
:ref:`full user guide <user_guide>` for further details, as the raw specifications of
classes and functions may not be enough to give full guidelines on their uses. For
reference on concepts repeated across the API, see :ref:`glossary`.

.. toctree::
:maxdepth: 2
:hidden:

{% for module, _ in API_REFERENCE %}
{{ module }}
{%- endfor %}
{%- if DEPRECATED_API_REFERENCE %}
deprecated
{%- endif %}

.. list-table::
:header-rows: 1
:class: apisearch-table

* - Object
- Description

{% for module, module_info in API_REFERENCE %}
{% for section in module_info["sections"] %}
{% for obj in section["autosummary"] %}
{% set parts = obj.rsplit(".", 1) %}
{% if parts|length > 1 %}
{% set full_module = module + "." + parts[0] %}
{% else %}
{% set full_module = module %}
{% endif %}
* - :obj:`~{{ module }}.{{ obj }}`

- .. div:: sk-apisearch-desc

.. currentmodule:: {{ full_module }}

.. autoshortsummary:: {{ module }}.{{ obj }}

.. div:: caption

:mod:`{{ full_module }}`
{% endfor %}
{% endfor %}
{% endfor %}

{% for ver, objs in DEPRECATED_API_REFERENCE %}
{% for obj in objs %}
{% set parts = obj.rsplit(".", 1) %}
{% if parts|length > 1 %}
{% set full_module = "sklearn." + parts[0] %}
{% else %}
{% set full_module = "sklearn" %}
{% endif %}
* - :obj:`~sklearn.{{ obj }}`

- .. div:: sk-apisearch-desc

.. currentmodule:: {{ full_module }}

.. autoshortsummary:: sklearn.{{ obj }}

.. div:: caption

:mod:`{{ full_module }}`
:bdg-ref-danger-line:`Deprecated in version {{ ver }} <api_depr_ref-{{ ver|replace(".", "-") }}>`
{% endfor %}
{% endfor %}
46 changes: 46 additions & 0 deletions doc/api/module.rst.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
:html_theme.sidebar_secondary.remove:

{%- if module == "sklearn" -%}
{%- set module_hook = "sklearn" -%}
{%- elif module.startswith("sklearn.") -%}
{%- set module_hook = module[8:] -%}
{%- else -%}
{%- set module_hook = None -%}
{%- endif -%}

{% if module_hook %}
.. _{{ module_hook }}_ref:
{% endif %}

{{ module }}
{{ "=" * module|length }}

.. automodule:: {{ module }}

{% if module_info["description"] %}
{{ module_info["description"] }}
{% endif %}

{% for section in module_info["sections"] %}
{% if section["title"] and module_hook %}
.. _{{ module_hook }}_ref-{{ section["title"]|lower|replace(" ", "-") }}:
{% endif %}

{% if section["title"] %}
{{ section["title"] }}
{{ "-" * section["title"]|length }}
{% endif %}

{% if section["description"] %}
{{ section["description"] }}
{% endif %}

.. autosummary::
:nosignatures:
:toctree: ../modules/generated/
:template: base.rst

{% for obj in section["autosummary"] %}
{{ obj }}
{%- endfor %}
{% endfor %}
Loading