Skip to content

Commit

Permalink
Merge pull request #1092 from streamlit/platform/autofunction-class-a…
Browse files Browse the repository at this point in the history
…ttribures

Autofunction: Let class docstring override @Property functions
  • Loading branch information
sfc-gh-dmatthews authored Jun 20, 2024
2 parents b97991a + 882a85e commit 811c7ea
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/blocks/autofunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,15 @@ const Autofunction = ({
footers.push({ title: "Warning", body: functionObject.warning });
}

// propertiesRows is initialized early to allow "Parameters" in any class
// docstring to be diverted to the properties section. Docstring parsing
// needs modification to first recognize "Attributes" or "Properites" then
// parse their contents.
// propertiesRows is initialized early to allow Attributes (recorded as args)
// in any class docstring to be diverted to the properties section.
let propertiesRows = [];
let docstringProperties = []; // Used to avoid duplicates with @property

for (const index in functionObject.args) {
const row = {};
const param = functionObject.args[index];
docstringProperties.push(param.name);
const isDeprecated =
param.deprecated && param.deprecated.deprecated === true;
const deprecatedMarkup = isDeprecated
Expand Down Expand Up @@ -420,6 +420,10 @@ const Autofunction = ({
for (const index in properties) {
const row = {};
const property = properties[index];
// If attribute is in class docstring don't also show the same @property.
if (docstringProperties.includes(property.name)) {
continue;
}
const slicedSlug = slug.slice().join("/");
const hrefName = `${functionObject.name}.${property.name}`
.toLowerCase()
Expand Down

0 comments on commit 811c7ea

Please sign in to comment.