Skip to content

Commit 15d5a74

Browse files
Add Autofunction option to show experimental precursor (#1002)
* Autofunction option: show experimental precursor * Use newer, shorter JS syntax * Use oldName/oldStreamlitFunction for code clarity
1 parent 0f7726f commit 15d5a74

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

components/blocks/autofunction.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const Autofunction = ({
3131
hideHeader,
3232
deprecated,
3333
deprecatedText,
34+
oldStreamlitFunction,
3435
}) => {
3536
const blockRef = useRef();
3637
const router = useRouter();
@@ -133,7 +134,8 @@ const Autofunction = ({
133134
};
134135

135136
const handleSelectVersion = (event) => {
136-
const functionObject = streamlit[streamlitFunction];
137+
const functionObject =
138+
streamlit[streamlitFunction] ?? streamlit[oldStreamlitFunction];
137139
const slicedSlug = slug.slice();
138140

139141
if (event.target.value !== currentVersion) {
@@ -170,8 +172,9 @@ const Autofunction = ({
170172
let methods = [];
171173
let properties = [];
172174

173-
if (streamlitFunction in streamlit) {
174-
functionObject = streamlit[streamlitFunction];
175+
if (streamlitFunction in streamlit || oldStreamlitFunction in streamlit) {
176+
functionObject =
177+
streamlit[streamlitFunction] ?? streamlit[oldStreamlitFunction];
175178
isClass = functionObject.is_class;
176179
if (
177180
functionObject.description !== undefined &&

pages/[...slug].js

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export default function Article({
155155
version={version}
156156
versions={versions}
157157
slug={slug}
158+
oldStreamlitFunction={props.oldName ?? ""}
158159
/>
159160
),
160161
pre: (props) => <Code {...props} />,

0 commit comments

Comments
 (0)