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

feat: list declarations under a public module if applicable #645

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0285c1c
feat(package-parser): store which module re-export a declaration
lars-reimann Jun 14, 2022
31c1658
chore(data): update sklearn API data
lars-reimann Jun 14, 2022
725ee2b
feat(gui): move declarations to public module that reexports them
lars-reimann Jun 14, 2022
f07a823
fix(package-parser): only store reexports from public modules
lars-reimann Jun 14, 2022
5f3355f
fix(gui): handle case that declaration is reexported multiple times
lars-reimann Jun 14, 2022
abe0a1e
fix(package-parser): two functions wrongly marked as public
lars-reimann Jun 14, 2022
e660e08
refactor(gui): simplify interface of PythonDeclaration
lars-reimann Jun 14, 2022
45d0573
fix(package-parser): missing public reexports
lars-reimann Jun 14, 2022
20dba36
Revert "fix(package-parser): missing public reexports"
lars-reimann Jun 14, 2022
ace3078
chore(data): update API data
lars-reimann Jun 14, 2022
46abef3
fix(package-parser): detect reexports over multiple levels
lars-reimann Jun 14, 2022
ecc9b26
refactor(gui): use iteration rather than recursion
lars-reimann Jun 14, 2022
d758ce5
fix(gui): previous/next not working after sorting
lars-reimann Jun 14, 2022
fb910e5
fix(gui): previous/next not expanding up to parameters
lars-reimann Jun 14, 2022
7a3f4cc
fix(gui): another issue with previous/next
lars-reimann Jun 14, 2022
44ffd21
fix(gui): reimplement sorting & next/previous
lars-reimann Jun 14, 2022
dbb165b
style: fix linter errors
lars-reimann Jun 14, 2022
37a95de
style: fix linter errors
lars-reimann Jun 14, 2022
d6903a6
style: apply automatic fixes of linters
lars-reimann Jun 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions api-editor/gui/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,21 @@ import {
initializeUI,
persistUI,
selectCurrentUserAction,
selectFilter,
selectShowAnnotationImportDialog,
selectShowAPIImportDialog,
selectShowUsageImportDialog,
selectUI,
setFilterString,
} from '../features/ui/uiSlice';
import { initializeUsages, persistUsages, selectUsages } from '../features/usages/usageSlice';
import {
initializePythonPackage,
selectFilteredPythonPackage,
selectPythonPackage,
} from '../features/packageData/apiSlice';
import { initializePythonPackage, selectRawPythonPackage } from '../features/packageData/apiSlice';
import { PythonClass } from '../features/packageData/model/PythonClass';
import { PythonParameter } from '../features/packageData/model/PythonParameter';

export const App: React.FC = function () {
useIndexedDB();

const pythonPackage = useAppSelector(selectPythonPackage);
const usages = useAppSelector(selectUsages);
const pythonFilter = useAppSelector(selectFilter);
const filteredPythonPackage = useAppSelector(selectFilteredPythonPackage);
const pythonPackage = useAppSelector(selectRawPythonPackage);

const [showInferErrorDialog, setShowInferErrorDialog] = useState(false);
const [inferErrors, setInferErrors] = useState<string[]>([]);
Expand All @@ -68,7 +60,7 @@ export const App: React.FC = function () {
};

const currentUserAction = useAppSelector(selectCurrentUserAction);
const userActionTarget = pythonPackage.getByRelativePathAsString(currentUserAction.target);
const userActionTarget = pythonPackage.getDeclarationById(currentUserAction.target);
const showAnnotationImportDialog = useAppSelector(selectShowAnnotationImportDialog);
const showAPIImportDialog = useAppSelector(selectShowAPIImportDialog);
const showUsagesImportDialog = useAppSelector(selectShowUsageImportDialog);
Expand Down Expand Up @@ -125,17 +117,15 @@ export const App: React.FC = function () {
/>
)}
{currentUserAction.type === 'move' && <MoveForm target={userActionTarget || pythonPackage} />}
{currentUserAction.type === 'none' && (
<TreeView pythonPackage={filteredPythonPackage} filter={pythonFilter} usages={usages} />
)}
{currentUserAction.type === 'none' && <TreeView />}
{currentUserAction.type === 'optional' && (
<OptionalForm target={userActionTarget || pythonPackage} />
)}
{currentUserAction.type === 'rename' && <RenameForm target={userActionTarget || pythonPackage} />}
{currentUserAction.type === 'todo' && <TodoForm target={userActionTarget || pythonPackage} />}
</GridItem>
<GridItem gridArea="rightPane" overflow="auto">
<SelectionView pythonPackage={pythonPackage} pythonFilter={pythonFilter} usages={usages} />
<SelectionView />
</GridItem>

{showAnnotationImportDialog && <AnnotationImportDialog />}
Expand Down
4 changes: 2 additions & 2 deletions api-editor/gui/src/common/GenerateAdapters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import React, { useRef, useState } from 'react';
import { useAppSelector } from '../app/hooks';
import { selectAnnotations } from '../features/annotations/annotationSlice';
import { AnnotatedPythonPackageBuilder } from '../features/annotatedPackageData/model/AnnotatedPythonPackageBuilder';
import { selectPythonPackage } from '../features/packageData/apiSlice';
import { selectRawPythonPackage } from '../features/packageData/apiSlice';

interface GenerateAdaptersProps {
displayInferErrors: (errors: string[]) => void;
Expand All @@ -31,7 +31,7 @@ export const GenerateAdapters: React.FC<GenerateAdaptersProps> = function ({ dis
const cancelRef = useRef(null);

const annotationStore = useAppSelector(selectAnnotations);
const pythonPackage = useAppSelector(selectPythonPackage);
const pythonPackage = useAppSelector(selectRawPythonPackage);

const packageNameIsValid = !shouldValidate || newPackageName !== '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
InferableBoundaryAnnotation,
InferableCalledAfterAnnotation,
InferableConstantAnnotation,
InferableDescriptionAnnotation,
InferableEnumAnnotation,
InferableGroupAnnotation,
InferableMoveAnnotation,
Expand All @@ -25,7 +26,6 @@ import {
InferableRemoveAnnotation,
InferableRenameAnnotation,
InferableRequiredAnnotation,
InferableDescriptionAnnotation,
InferableTodoAnnotation,
} from './InferableAnnotation';

Expand All @@ -44,7 +44,7 @@ export class AnnotatedPythonPackageBuilder {
this.pythonPackage.distribution,
this.pythonPackage.version,
this.#buildAnnotatedPythonModules(this.pythonPackage.modules),
this.#getExistingAnnotations(this.pythonPackage.pathAsString()),
this.#getExistingAnnotations(this.pythonPackage.id),
);
}

Expand All @@ -57,7 +57,7 @@ export class AnnotatedPythonPackageBuilder {
pythonModule.fromImports,
this.#buildAnnotatedPythonClasses(pythonModule),
this.#buildAnnotatedPythonFunctions(pythonModule),
this.#getExistingAnnotations(pythonModule.pathAsString()),
this.#getExistingAnnotations(pythonModule.id),
),
);
}
Expand All @@ -74,7 +74,7 @@ export class AnnotatedPythonPackageBuilder {
pythonClass.isPublic,
pythonClass.description,
pythonClass.fullDocstring,
this.#getExistingAnnotations(pythonClass.pathAsString()),
this.#getExistingAnnotations(pythonClass.id),
),
);
}
Expand All @@ -101,7 +101,7 @@ export class AnnotatedPythonPackageBuilder {
pythonFunction.isPublic,
pythonFunction.description,
pythonFunction.fullDocstring,
this.#getExistingAnnotations(pythonFunction.pathAsString()),
this.#getExistingAnnotations(pythonFunction.id),
);
}

Expand All @@ -119,7 +119,7 @@ export class AnnotatedPythonPackageBuilder {
pythonParameter.isPublic,
pythonParameter.typeInDocs,
pythonParameter.description,
this.#getExistingAnnotations(pythonParameter.pathAsString()),
this.#getExistingAnnotations(pythonParameter.id),
),
);
}
Expand All @@ -132,7 +132,7 @@ export class AnnotatedPythonPackageBuilder {
pythonResult.typeInDocs,
pythonResult.typeInDocs,
pythonResult.description,
this.#getExistingAnnotations(pythonResult.pathAsString()),
this.#getExistingAnnotations(pythonResult.id),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface AttributeFormProps {
}

export const AttributeForm: React.FC<AttributeFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;

// Hooks -----------------------------------------------------------------------------------------------------------
const previousAnnotation = useAppSelector(selectAttribute(targetPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const initialFormState = function (previousInterval: Optional<Interval>): Bounda
};

export const BoundaryForm: React.FC<BoundaryFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;
const prevInterval = useAppSelector(selectBoundary(targetPath))?.interval;

// Hooks -----------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface CalledAfterFormState {
}

export const CalledAfterForm: React.FC<CalledAfterFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;
const currentCalledAfters = Object.keys(useAppSelector(selectCalledAfters(targetPath)));

const remainingCalledAfters = target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ConstantFormProps {
}

export const ConstantForm: React.FC<ConstantFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;

// Hooks -----------------------------------------------------------------------------------------------------------
const constantDefinition = useAppSelector(selectConstant(targetPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface DescriptionFormState {
}

export const DescriptionForm: React.FC<DescriptionFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;
const prevNewDescription = useAppSelector(selectDescription(targetPath))?.newDescription;
const oldDescription = target.description;

Expand Down
4 changes: 2 additions & 2 deletions api-editor/gui/src/features/annotations/forms/EnumForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ interface EnumFormState {
}

export const EnumForm: React.FC<EnumFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;

// Hooks -----------------------------------------------------------------------------------------------------------
const enumDefinition = useAppSelector(selectEnum(target.pathAsString()));
const enumDefinition = useAppSelector(selectEnum(target.id));
const dispatch = useAppDispatch();

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface GroupFormState {
}

export const GroupForm: React.FC<GroupFormProps> = function ({ target, groupName }) {
const targetPath = target.pathAsString();
const targetPath = target.id;
const currentGroups = useAppSelector(selectGroups(targetPath));
let prevGroupAnnotation: GroupAnnotation | undefined;
if (groupName && currentGroups) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface MoveFormState {
}

export const MoveForm: React.FC<MoveFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;
const prevDestination = useAppSelector(selectMove(targetPath))?.destination;
const oldModulePath = target?.parent()?.name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface OptionalFormProps {
}

export const OptionalForm: React.FC<OptionalFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;

// Hooks -----------------------------------------------------------------------------------------------------------
const optionalDefinition = useAppSelector(selectOptional(targetPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface RenameFormState {
}

export const RenameForm: React.FC<RenameFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;
const prevNewName = useAppSelector(selectRenaming(targetPath))?.newName;
const oldName = target.name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface TodoFormState {
}

export const TodoForm: React.FC<TodoFormProps> = function ({ target }) {
const targetPath = target.pathAsString();
const targetPath = target.id;
const prevNewTodo = useAppSelector(selectTodo(targetPath))?.newTodo;

// Hooks -----------------------------------------------------------------------------------------------------------
Expand Down
Loading