Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 24dc499

Browse files
authored
feat(gui): show parameter descriptions in group form (#974)
* feat(gui): show parameter descriptions in group form * style: apply automatic fixes of linters Co-authored-by: lars-reimann <[email protected]>
1 parent fecf5c5 commit 24dc499

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

api-editor/gui/src/features/annotations/forms/GroupForm.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
Box,
23
Checkbox,
34
FormControl,
45
FormErrorIcon,
@@ -19,6 +20,7 @@ import { AnnotationForm } from './AnnotationForm';
1920
import { hideAnnotationForm } from '../../ui/uiSlice';
2021
import { selectGroupAnnotations, upsertGroupAnnotation } from '../annotationSlice';
2122
import { GroupAnnotation } from '../versioning/AnnotationStoreV2';
23+
import { DocumentationText } from '../../packageData/selectionView/DocumentationText';
2224

2325
interface GroupFormProps {
2426
readonly target: PythonDeclaration;
@@ -163,9 +165,20 @@ export const GroupForm: React.FC<GroupFormProps> = function ({ target, groupName
163165
<FormControl isInvalid={Boolean(errors?.parameters)}>
164166
<VStack alignItems="left">
165167
{allParameters.map((parameter) => (
166-
<Checkbox key={parameter.name} {...register(`parameters.${parameter.name}`)}>
167-
{getParameterLabel(parameter.name)}
168-
</Checkbox>
168+
<Box key={parameter.name}>
169+
<Checkbox {...register(`parameters.${parameter.name}`)}>
170+
{getParameterLabel(parameter.name)}
171+
</Checkbox>
172+
{parameter.description && (
173+
<Box m={4}>
174+
<DocumentationText
175+
declaration={parameter}
176+
inputText={parameter.description}
177+
alwaysExpanded
178+
></DocumentationText>
179+
</Box>
180+
)}
181+
</Box>
169182
))}
170183
</VStack>
171184
</FormControl>

api-editor/gui/src/features/packageData/selectionView/DocumentationText.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { PythonModule } from '../model/PythonModule';
3737
interface DocumentationTextProps {
3838
declaration: PythonDeclaration;
3939
inputText: string;
40+
alwaysExpanded?: boolean;
4041
}
4142

4243
type ParagraphComponent = FunctionComponent<
@@ -71,7 +72,11 @@ const CustomText: ParagraphComponent = function ({ className, children }) {
7172
};
7273

7374
const CustomUnorderedList: UnorderedListComponent = function ({ className, children }) {
74-
return <UnorderedList className={className}>{children}</UnorderedList>;
75+
return (
76+
<UnorderedList className={className} pl={2}>
77+
{children}
78+
</UnorderedList>
79+
);
7580
};
7681

7782
const components = {
@@ -81,7 +86,11 @@ const components = {
8186
ul: CustomUnorderedList,
8287
};
8388

84-
export const DocumentationText: React.FC<DocumentationTextProps> = function ({ declaration, inputText = '' }) {
89+
export const DocumentationText: React.FC<DocumentationTextProps> = function ({
90+
declaration,
91+
inputText = '',
92+
alwaysExpanded = false,
93+
}) {
8594
const expandDocumentationByDefault = useAppSelector(selectExpandDocumentationByDefault);
8695

8796
const preprocessedText = inputText
@@ -113,7 +122,12 @@ export const DocumentationText: React.FC<DocumentationTextProps> = function ({ d
113122
resolveAbsoluteLink(declaration, qualifiedName, 2),
114123
);
115124

116-
const shortenedText = preprocessedText.split('\n\n')[0];
125+
let shortenedText;
126+
if (alwaysExpanded) {
127+
shortenedText = preprocessedText;
128+
} else {
129+
shortenedText = preprocessedText.split('\n\n')[0];
130+
}
117131
const hasMultipleLines = shortenedText !== preprocessedText;
118132
const [readMore, setReadMore] = useState(expandDocumentationByDefault);
119133

0 commit comments

Comments
 (0)