Skip to content

Commit

Permalink
Reduce bloat in streamlit.json and significantly reduce API load time (
Browse files Browse the repository at this point in the history
…#883)

* Add `only_include` param to get_obj_docstring_dict

* Trim streamlit.json to only include .add_rows & .update on Deltageneator and StatusContainer

* TEMP manual fix for connection .query methods

---------

Co-authored-by: Debbie Matthews <[email protected]>
  • Loading branch information
snehankekre and sfc-gh-dmatthews authored Nov 18, 2023
1 parent 116ba9b commit d861a0b
Show file tree
Hide file tree
Showing 2 changed files with 23,727 additions and 87,419 deletions.
22 changes: 11 additions & 11 deletions python/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
import types

import docstring_parser
import stoutput
import streamlit
import streamlit.components.v1 as components
from streamlit.elements.lib.mutable_status_container import StatusContainer
from streamlit.testing.v1.app_test import AppTest
import streamlit.testing.v1.element_tree as element_tree
import utils
from docutils.core import publish_parts
from docutils.parsers.rst import directives
from numpydoc.docscrape import NumpyDocString

import stoutput
import utils
from streamlit.elements.lib.mutable_status_container import StatusContainer
from streamlit.testing.v1.app_test import AppTest

VERSION = streamlit.__version__

Expand Down Expand Up @@ -378,7 +377,7 @@ def get_sig_string_without_annots(func):
return ", ".join(args)


def get_obj_docstring_dict(obj, key_prefix, signature_prefix):
def get_obj_docstring_dict(obj, key_prefix, signature_prefix, only_include=None):
"""Recursively get the docstring dict for an object and its members. Returns a dict of dicts containing the docstring info for each member."""

# Initialize empty dictionary to store function/method/property metadata
Expand All @@ -390,8 +389,9 @@ def get_obj_docstring_dict(obj, key_prefix, signature_prefix):
if membername.startswith("_"):
continue

# if membername == "column_config":
# continue
# Skip members that are not included in only_include
if only_include is not None and membername not in only_include:
continue

# Get the member object using its name
member = getattr(obj, membername)
Expand Down Expand Up @@ -504,8 +504,8 @@ def get_streamlit_docstring_dict():
],
streamlit.column_config: ["streamlit.column_config", "st.column_config"],
components: ["streamlit.components.v1", "st.components.v1"],
streamlit._DeltaGenerator: ["DeltaGenerator", "element"],
StatusContainer: ["StatusContainer", "StatusContainer"],
streamlit._DeltaGenerator: ["DeltaGenerator", "element", "add_rows"], # Only store docstring for element.add_rows
StatusContainer: ["StatusContainer", "StatusContainer", "update"], # Only store docstring for StatusContainer.update
streamlit.testing.v1: ["streamlit.testing.v1", "st.testing.v1"],
AppTest: ["AppTest", "AppTest"],
element_tree: [
Expand All @@ -516,7 +516,7 @@ def get_streamlit_docstring_dict():

module_docstring_dict = {}
for obj, key in obj_key.items():
module_docstring_dict.update(get_obj_docstring_dict(obj, key[0], key[1]))
module_docstring_dict.update(get_obj_docstring_dict(obj, *key))

return module_docstring_dict

Expand Down
Loading

0 comments on commit d861a0b

Please sign in to comment.