diff --git a/api-editor/gui/src/features/packageData/model/APIJsonData.ts b/api-editor/gui/src/features/packageData/model/APIJsonData.ts index ca93db6c9..86ef27963 100644 --- a/api-editor/gui/src/features/packageData/model/APIJsonData.ts +++ b/api-editor/gui/src/features/packageData/model/APIJsonData.ts @@ -68,6 +68,7 @@ export interface PythonParameterJson { docstring: { type: Optional; description: Optional; + default_value: Optional; }; type: object; // TODO parse type } diff --git a/api-editor/gui/src/features/packageData/model/PythonPackageBuilder.ts b/api-editor/gui/src/features/packageData/model/PythonPackageBuilder.ts index 9c3f74027..a395d33d3 100644 --- a/api-editor/gui/src/features/packageData/model/PythonPackageBuilder.ts +++ b/api-editor/gui/src/features/packageData/model/PythonPackageBuilder.ts @@ -159,6 +159,7 @@ const parsePythonParameterJson = function ( parameterJson.docstring.type ?? '', parameterJson.docstring.description ?? '', parameterJson.type, + parameterJson.docstring.default_value ?? '', ); idToDeclaration.set(parameterJson.id, result); return result; diff --git a/api-editor/gui/src/features/packageData/model/PythonParameter.ts b/api-editor/gui/src/features/packageData/model/PythonParameter.ts index 0bcca3395..7839b66b6 100644 --- a/api-editor/gui/src/features/packageData/model/PythonParameter.ts +++ b/api-editor/gui/src/features/packageData/model/PythonParameter.ts @@ -29,6 +29,7 @@ export class PythonParameter extends PythonDeclaration { readonly typeInDocs: string = '', readonly description: string = '', readonly type: object = {}, + readonly defaultValueInDocs: Optional = null, ) { super(); @@ -85,6 +86,7 @@ export class PythonParameter extends PythonDeclaration { docstring: { type: this.typeInDocs, description: this.description, + default_value: this.defaultValueInDocs, }, type: this.type, }; @@ -100,6 +102,8 @@ export class PythonParameter extends PythonDeclaration { this.isPublic, this.typeInDocs, this.description, + this.type, + this.defaultValueInDocs, ); result.containingFunction = this.containingFunction; return result; diff --git a/api-editor/gui/src/features/packageData/selectionView/ParameterView.tsx b/api-editor/gui/src/features/packageData/selectionView/ParameterView.tsx index 1e5c42af7..17f43073b 100644 --- a/api-editor/gui/src/features/packageData/selectionView/ParameterView.tsx +++ b/api-editor/gui/src/features/packageData/selectionView/ParameterView.tsx @@ -1,4 +1,4 @@ -import { Box, Heading, Stack, Text as ChakraText, useColorModeValue } from '@chakra-ui/react'; +import { Box, Heading, HStack, Stack, Text as ChakraText, useColorModeValue } from '@chakra-ui/react'; import React from 'react'; import { PythonParameter } from '../model/PythonParameter'; import { ParameterNode } from './ParameterNode'; @@ -39,12 +39,36 @@ export const ParameterView: React.FC = function ({ pythonPar )} - {pythonParameter.defaultValue && ( + {pythonParameter && ( Default Value - {pythonParameter.defaultValue} + + {pythonParameter.defaultValue ? ( + + Code: {pythonParameter.defaultValue} + + {pythonParameter.defaultValueInDocs ? ( + + Documentation: {pythonParameter.defaultValueInDocs} + + ) : ( + + + Documentation:{' '} + + The documentation does not specify a default value. + + + + )} + + ) : ( + + The parameter is required. + + )} )} @@ -126,12 +150,8 @@ const CustomBarChart: React.FC = function ({ parameterUsage datasets: [ { data: labels.map((key) => sortedParameterUsages.get(key)), - borderColor: labels.map((key) => - isStringifiedLiteral(key) ? 'rgba(137, 87, 229, 1)' : 'rgba(136, 136, 136, 1)', - ), - backgroundColor: labels.map((key) => - isStringifiedLiteral(key) ? 'rgba(137, 87, 229, 0.2)' : 'rgba(136, 136, 136, 0.2)', - ), + borderColor: labels.map((key) => (isStringifiedLiteral(key) ? '#871F78' : '#888888')), + backgroundColor: labels.map((key) => (isStringifiedLiteral(key) ? '#871F78' : '#888888')), }, ], };