Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adds component prop documentation #2541

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d5c1900
extract API docs from typedoc
nicholasrice Dec 16, 2019
ba77e5f
correct table syntax
nicholasrice Dec 16, 2019
db1f8da
get typedoc building better
nicholasrice Dec 16, 2019
b5905c4
gets class-name contracts to compile
nicholasrice Dec 17, 2019
28f059e
progress
nicholasrice Dec 17, 2019
85e02eb
reverting files to use utility-types
nicholasrice Dec 17, 2019
60252a6
add concat-md
nicholasrice Dec 17, 2019
e506310
adding document script
nicholasrice Dec 18, 2019
8864464
progress
nicholasrice Dec 18, 2019
d691032
progress
nicholasrice Dec 18, 2019
4292f3d
resolving dependencies
nicholasrice Dec 23, 2019
809cdcb
concat files and format inputs
nicholasrice Dec 23, 2019
b338fe9
output to tmp directory
nicholasrice Dec 23, 2019
c785954
fixing storybook build
nicholasrice Dec 24, 2019
bbb17b9
plugging documentation into storybook
nicholasrice Dec 24, 2019
84a9a37
add api docs to breadcrumb
nicholasrice Dec 28, 2019
3453d46
plugin api docs into storybook
nicholasrice Dec 28, 2019
3a98457
fixing syntax
nicholasrice Dec 28, 2019
5ccc207
remove unused code
nicholasrice Dec 29, 2019
98f6fa6
add API.md files to dist
nicholasrice Dec 29, 2019
6794c85
wire API docs to components
nicholasrice Dec 30, 2019
a7b6894
remove newlines
nicholasrice Dec 30, 2019
a66fd04
fixing break
nicholasrice Dec 30, 2019
356efb7
enable dynamic imports
nicholasrice Dec 30, 2019
4464563
add dynamic import component
nicholasrice Dec 30, 2019
bd4fbb3
dynamic imports!
nicholasrice Dec 30, 2019
13f9437
fixing links
nicholasrice Dec 30, 2019
d1512ca
adjust typings to accept null API component
nicholasrice Dec 31, 2019
fab71a4
fixing tests
nicholasrice Dec 31, 2019
5829fcb
adding bug refernce to TODO
nicholasrice Dec 31, 2019
44d5b0c
prettier
nicholasrice Jan 3, 2020
3b45592
convert API prior to testing
nicholasrice Jan 3, 2020
f59b136
fix yarn lock conflict
nicholasrice Jan 15, 2020
147dc4f
fixing yarn.lock conflicts
nicholasrice Jan 27, 2020
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ docs/en/packages/*/README.md
# TypeDoc generated subsites
docs/en/packages/*/api/

# MSFT Documentation
## Ignore compiled helper files
packages/fast-components-react-msft/typedoc-theme/helpers/*

## Ignore typedoc output
packages/fast-components-react-msft/api/

## Ignore generated API documentation files
packages/fast-components-react-msft/src/**/API.md
30 changes: 0 additions & 30 deletions build/copy-readme.js

This file was deleted.

37 changes: 37 additions & 0 deletions build/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Utility for copying readme to their dist folders.
* Usage: node build/copy-readme.js
* @arg src - globbing pattern targeting source files
* @arg dist - the dist directory
*/
const path = require("path");
const fs = require("fs");
const glob = require("glob");

function getArg(raw, required = false) {
const index = process.argv.indexOf(raw);

if (index === -1) {
if (required) {
throw new Error(`Required argument "${raw}" was not provided`);
}
} else {
return process.argv[index + 1];
}
}

const rootDir = path.resolve(process.cwd());
const srcReadmePaths = getArg("--src", true);
const destDir = getArg("--dist", true);
const resolvedSrcReadmePaths = path.resolve(rootDir, srcReadmePaths);

glob(resolvedSrcReadmePaths, void 0, function(error, files) {
if (error) {
throw error;
}

files.forEach(filePath => {
const destReadmePath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir);
fs.copyFileSync(filePath, destReadmePath);
});
});
32 changes: 32 additions & 0 deletions packages/fast-component-explorer/app/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,38 @@ class Explorer extends Foundation<
},
id: "schema",
},
{
tab: (className: string): React.ReactNode => {
return (
<Typography
className={className}
size={TypographySize._8}
onClick={this.handleDevToolsTabTriggerClick}
>
API
</Typography>
);
},
content: (className: string): React.ReactNode => {
const componentName: string = this.getComponentNameSpinalCaseByPath(
this.state.locationPathname
);
const API: React.ComponentClass = get(
setViewConfigsWithCustomConfig(
componentViewConfigsWithoutCustomConfig
),
`${camelCase(componentName)}Config.api`,
null
) as any;

return (
<div className={className}>
<API />
</div>
);
},
id: "api",
},
];
}

Expand Down
20 changes: 20 additions & 0 deletions packages/fast-component-explorer/app/utilities/api.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import { Progress } from "@microsoft/fast-components-react-msft";

export default function API(
Component: ReturnType<typeof React.lazy>
): React.ComponentClass<{}, {}> {
return class APIRenderer extends React.Component<{}, {}> {
public render(): JSX.Element {
return (
<React.Suspense
fallback={
<Progress circular={true} style={{ margin: "24px auto 0" }} />
}
>
<Component />
</React.Suspense>
);
}
};
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
AccentButton,
Expand All @@ -6,8 +7,10 @@ import {
} from "@microsoft/fast-components-react-msft";
import Guidance from "../../.tmp/accent-button/guidance";
import { glyphSchema, Icon } from "../../../app/components/glyph";
import API from "../api";

const accentButtonConfig: ComponentViewConfig<AccentButtonProps> = {
api: API(React.lazy(() => import("../../.tmp/accent-button/api"))),
schema: accentButtonSchema,
component: AccentButton,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
ActionToggle,
Expand All @@ -7,8 +8,10 @@ import {
} from "@microsoft/fast-components-react-msft";
import { glyphSchema, Icon } from "../../../app/components/glyph";
import Guidance from "../../.tmp/action-toggle/guidance";
import API from "../api";

const actionToggleConfig: ComponentViewConfig<ActionToggleProps> = {
api: API(React.lazy(() => import("../../.tmp/action-toggle/api"))),
schema: actionToggleSchema,
component: ActionToggle,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
ActionTrigger,
Expand All @@ -7,8 +8,10 @@ import {
} from "@microsoft/fast-components-react-msft";
import { glyphSchema, Icon } from "../../../app/components/glyph";
import Guidance from "../../.tmp/action-trigger/guidance";
import API from "../api";

const actionTriggerConfig: ComponentViewConfig<ActionTriggerProps> = {
api: API(React.lazy(() => import("../../.tmp/action-trigger/guidance"))),
schema: actionTriggerSchema,
component: ActionTrigger,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
AutoSuggestOption,
Expand All @@ -6,8 +7,10 @@ import {
} from "@microsoft/fast-components-react-msft";
import { uniqueId } from "lodash-es";
import Guidance from "../../.tmp/auto-suggest-option/guidance";
import API from "../api";

const autoSuggestOptionConfig: ComponentViewConfig<AutoSuggestOptionProps> = {
api: API(React.lazy(() => import("../../.tmp/auto-suggest-option/api"))),
schema: autoSuggestOptionSchema,
component: AutoSuggestOption,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
AutoSuggest,
Expand All @@ -8,6 +9,7 @@ import {
} from "@microsoft/fast-components-react-msft";
import { uniqueId } from "lodash-es";
import Guidance from "../../.tmp/auto-suggest/guidance";
import API from "../api";

function autoSuggestOptionPropFactory(value: string): AutoSuggestOptionProps {
return {
Expand All @@ -18,6 +20,7 @@ function autoSuggestOptionPropFactory(value: string): AutoSuggestOptionProps {
}

const autoSuggestConfig: ComponentViewConfig<AutoSuggestProps> = {
api: API(React.lazy(() => import("../../.tmp/auto-suggest/api"))),
schema: autoSuggestSchema,
component: AutoSuggest,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
Badge,
Expand All @@ -6,8 +7,10 @@ import {
BadgeSize,
} from "@microsoft/fast-components-react-msft";
import Guidance from "../../.tmp/badge/guidance";
import API from "../api";

const badgeConfig: ComponentViewConfig<BadgeProps> = {
api: API(React.lazy(() => import("../../.tmp/badge/api"))),
schema: badgeSchema,
component: Badge,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
Breadcrumb,
Expand All @@ -7,8 +8,10 @@ import {
} from "@microsoft/fast-components-react-msft";
import { groupSchema } from "../../../app/components/group";
import Guidance from "../../.tmp/breadcrumb/guidance";
import API from "../api";

const breadcrumbConfig: ComponentViewConfig<BreadcrumbProps> = {
api: API(React.lazy(() => import("../../.tmp/breadcrumb/api"))),
schema: breadcrumbSchema,
component: Breadcrumb,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
Button,
Expand All @@ -6,8 +7,10 @@ import {
buttonSchema,
} from "@microsoft/fast-components-react-msft";
import Guidance from "../../.tmp/button/guidance";
import API from "../api";

const buttonConfig: ComponentViewConfig<ButtonProps> = {
api: API(React.lazy(() => import("../../.tmp/button/api"))),
schema: buttonSchema,
component: Button,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
CallToAction,
Expand All @@ -6,8 +7,10 @@ import {
callToActionSchema,
} from "@microsoft/fast-components-react-msft";
import Guidance from "../../.tmp/call-to-action/guidance";
import API from "../api";

const callToActionConfig: ComponentViewConfig<CallToActionProps> = {
api: API(React.lazy(() => import("../../.tmp/call-to-action/api"))),
schema: callToActionSchema,
component: CallToAction,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
Caption,
CaptionProps,
captionSchema,
} from "@microsoft/fast-components-react-msft";
import Guidance from "../../.tmp/caption/guidance";
import API from "../api";

const captionConfig: ComponentViewConfig<CaptionProps> = {
api: API(React.lazy(() => import("../../.tmp/caption/api"))),
schema: captionSchema,
component: Caption,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
Card,
Expand All @@ -6,8 +7,10 @@ import {
imageSchema,
} from "@microsoft/fast-components-react-msft";
import Guidance from "../../.tmp/card/guidance";
import API from "../api";

const cardConfig: ComponentViewConfig<CardProps> = {
api: API(React.lazy(() => import("../../.tmp/card/api"))),
schema: cardSchema,
component: Card,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
CallToActionAppearance,
Expand All @@ -10,6 +11,7 @@ import {
} from "@microsoft/fast-components-react-msft";
import { uniqueId } from "lodash-es";
import Guidance from "../../.tmp/carousel/guidance";
import API from "../api";

const darkImageProps: object = {
props: {
Expand Down Expand Up @@ -69,6 +71,7 @@ const defaultTabItems: CarouselSlide[] = [
];

const carouselConfig: ComponentViewConfig<CarouselProps> = {
api: API(React.lazy(() => import("../../.tmp/carousel/api"))),
schema: carouselSchema,
component: Carousel,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
Checkbox,
Expand All @@ -7,10 +8,12 @@ import {
} from "@microsoft/fast-components-react-msft";
import { uniqueId } from "lodash-es";
import Guidance from "../../.tmp/checkbox/guidance";
import API from "../api";

const id: string = uniqueId();

const checkboxConfig: ComponentViewConfig<CheckboxProps> = {
api: API(React.lazy(() => import("../../.tmp/checkbox/api"))),
schema: checkboxSchema,
component: Checkbox,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
ContextMenuItem,
ContextMenuItemProps,
contextMenuItemSchema,
} from "@microsoft/fast-components-react-msft";
import Guidance from "../../.tmp/context-menu-item/guidance";
import API from "../api";

const contextMenuItemConfig: ComponentViewConfig<ContextMenuItemProps> = {
api: API(React.lazy(() => import("../../.tmp/context-menu-item/api"))),
schema: contextMenuItemSchema,
component: ContextMenuItem,
guidance: Guidance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentViewConfig } from "./data.props";
import {
ContextMenu,
Expand All @@ -6,8 +7,10 @@ import {
contextMenuSchema,
} from "@microsoft/fast-components-react-msft";
import Guidance from "../../.tmp/context-menu/guidance";
import API from "../api";

const contextMenuConfig: ComponentViewConfig<ContextMenuProps> = {
api: API(React.lazy(() => import("../../.tmp/context-menu/api"))),
schema: contextMenuSchema,
component: ContextMenu,
guidance: Guidance,
Expand Down
Loading