Skip to content
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

Add support for classes to generated python common API index #2401

Merged
merged 5 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
6 changes: 5 additions & 1 deletion rerun_py/docs/css/mkdocstrings.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ body {
color: inherit;
}

.md-typeset p + h1 {
.md-typeset p+h1 {
margin-top: 2rem;
}

Expand All @@ -51,3 +51,7 @@ code {
--md-code-bg-color: #e3e3e3;
font-family: "JetBrains Mono", monospace;
}

.md-typeset a {
--md-typeset-a-color: #526cfe;
}
39 changes: 34 additions & 5 deletions rerun_py/docs/gen_common_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Section:
title: str
module_summary: str | None
func_list: list[str]
class_list: list[str]


# This is the list of sections and functions that will be included in the index
Expand All @@ -50,16 +51,19 @@ class Section:
title="Initialization",
module_summary=None,
func_list=["init", "connect", "disconnect", "spawn", "serve", "memory_recording"],
class_list=[],
),
Section(
title="Viewer Control",
module_summary=None,
func_list=["save"],
class_list=[],
),
Section(
title="Time",
module_summary=None,
func_list=["set_time_sequence", "set_time_seconds", "set_time_nanos"],
class_list=[],
),
Section(
title="Spatial Primitives",
Expand All @@ -77,31 +81,37 @@ class Section:
"log_meshes",
"log_mesh_file",
],
class_list=[],
),
Section(
title="Images",
module_summary=None,
func_list=["log_image", "log_image_file", "log_depth_image", "log_segmentation_image"],
class_list=[],
),
Section(
title="Tensors",
module_summary=None,
func_list=["log_tensor"],
class_list=[],
),
Section(
title="Annotations",
module_summary=None,
func_list=["log_annotation_context"],
class_list=["ClassDescription", "AnnotationInfo"],
),
Section(
title="Extension Components",
module_summary=None,
func_list=["log_extension_components"],
class_list=[],
),
Section(
title="Plotting",
module_summary=None,
func_list=["log_scalar"],
class_list=[],
),
Section(
title="Transforms",
Expand All @@ -114,18 +124,21 @@ class Section:
"log_disconnected_space",
"log_view_coordinates",
],
class_list=[],
),
Section(
title="Text",
module_summary=None,
# TODO(#1251): Classes aren't supported yet
# "LogLevel", "LoggingHandler"
func_list=["log_text_entry"],
class_list=["LogLevel", "LoggingHandler"],
),
Section(
title="Helpers",
module_summary="script_helpers",
func_list=["script_add_args", "script_setup", "script_teardown"],
class_list=[],
),
Section(
title="Experimental",
Expand All @@ -137,6 +150,7 @@ class Section:
"experimental.set_panels",
"experimental.set_auto_space_views",
],
class_list=[],
),
]

Expand Down Expand Up @@ -208,14 +222,29 @@ def make_slug(s: str) -> str:
fd.write("----\n")
for func_name in section.func_list:
fd.write(f"::: rerun.{func_name}\n")
fd.write(" options:\n")
fd.write(" heading_level: 4\n")
for class_name in section.class_list:
# fd.write(f"::: rerun.{class_name}\n")
fd.write(f"::: rerun.{class_name}\n")
fd.write(" options:\n")
fd.write(" heading_level: 4\n")

# Write out a table for the section in the index_file
index_file.write(f"## {section.title}\n")
index_file.write("Function | Description\n")
index_file.write("-------- | -----------\n")
for func_name in section.func_list:
func = rerun_pkg[func_name]
index_file.write(f"[`rerun.{func_name}()`]({md_name}#rerun.{func_name}) | {func.docstring.lines[0]}\n")
if section.func_list:
index_file.write("Function | Description\n")
index_file.write("-------- | -----------\n")
for func_name in section.func_list:
func = rerun_pkg[func_name]
index_file.write(f"[`rerun.{func_name}()`]({md_name}#rerun.{func_name}) | {func.docstring.lines[0]}\n")
if section.class_list:
index_file.write("\n")
index_file.write("Class | Description\n")
index_file.write("-------- | -----------\n")
for class_name in section.class_list:
cls = rerun_pkg[class_name]
index_file.write(f"[`rerun.{class_name}`]({md_name}#rerun.{class_name}) | {cls.docstring.lines[0]}\n")

index_file.write("\n")

Expand Down
2 changes: 1 addition & 1 deletion rerun_py/docs/package/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Full Package

- [rerun][]: Top-level User-facing APIs. See also: [Common APIs](/common)
- [rerun][]: Top-level User-facing APIs. See also: [Common APIs](../common/)
- [rerun.log][]: APIs for logging data
- [rerun.color_conversion][]: Conversion utilities related to colors
- [rerun.components][]: Helpers for constructing arrow components
Expand Down
4 changes: 3 additions & 1 deletion rerun_py/docs/templates/python/material/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
{% set heading_level = heading_level - 1 %}
{% endif %}

<div class="doc doc-contents {% if root %}first{% endif %}">
{# CHANGE: disable gating of first for root docstring #}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have trouble parsing this sentence

{#<div class="doc doc-contents {% if root %}first{% endif %}">#}
<div class="doc doc-contents">
{% if config.show_bases and class.bases %}
<p class="doc doc-class-bases">
Bases: {% for expression in class.bases -%}
Expand Down
1 change: 0 additions & 1 deletion rerun_py/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ extra:
version:
provider: mike
default: latest