diff --git a/.editorconfig b/.editorconfig index 72611bed18..38d0a2a141 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,7 +13,7 @@ indent_size = 2 indent_style = space # some files use 4 spaces for indentation -[*.{js,jsx,ts,tsx,java,xml}] +[*.{js,jsx,ts,tsx,java,xml,md}] indent_size = 4 [*.java] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8001324e7e..e79788a9f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ A typical contributor workflow looks like this: 1. Create a new feature branch. We use a format like `[your-initials]/[short-name]`: `bd/refactor-buttons`. 1. Run the development server via `gulp` (no arguments). - - Navigate to http://localhost:9000/packages/docs/dist/ when the server starts. + - Navigate to http://localhost:9000/packages/docs-site/dist/ when the server starts. - See [Build tasks](https://github.com/palantir/blueprint/wiki/Build-tasks) on the wiki for more details on the inner workings of the Gulp build. - If you are contributing to the `table` or `landing` packages then run `npm start` in those diff --git a/Gulpfile.js b/Gulpfile.js index a7114a1576..98a7bb4d4d 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -71,11 +71,18 @@ const projects = [ }, { id: "docs", cwd: "packages/docs/", + dependencies: ["core"], + sass: "compile", + typescript: true, + }, { + id: "docs-site", + cwd: "packages/docs-site/", dependencies: [ // You must add your package to this dependency list if you have any // examples in the docs. "core", "datetime", + "docs", "table", ], sass: "bundle", @@ -87,6 +94,7 @@ const projects = [ // (they all import @blueprint/* but don't actually have themselves in their node_modules) "@blueprintjs/core", "@blueprintjs/datetime", + "@blueprintjs/docs", "@blueprintjs/table", "dom4", "moment", diff --git a/README.md b/README.md index b0c7265ce3..e2b3a006dc 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ __Prerequisite__: Node.js v6 or v7 1. `npm install` to install build dependencies 1. `npm run bootstrap` to install and link each package using [Lerna](https://lernajs.io/) 1. `npm run gulp` to compile and start the server and watcher -1. Open your browser to [localhost:9000/packages/docs/dist/](http://localhost:9000/packages/docs/dist/) +1. Open your browser to [localhost:9000/packages/docs-site/dist/](http://localhost:9000/packages/docs-site/dist/) ## Contributing diff --git a/circle.yml b/circle.yml index 9a57b6cccc..43381e1aef 100644 --- a/circle.yml +++ b/circle.yml @@ -4,6 +4,7 @@ general: - packages/core/dist - packages/datetime/dist - packages/docs/dist + - packages/docs-site/dist - packages/landing/dist - packages/table/dist # code coverage reports @@ -22,6 +23,7 @@ dependencies: - packages/core/node_modules - packages/datetime/node_modules - packages/docs/node_modules + - packages/docs-site/node_modules - packages/landing/node_modules - packages/table/node_modules # non-zero exit codes in `dependencies` group will fail the build early diff --git a/gulp/aliases.js b/gulp/aliases.js index 6bf2ba97b8..9cbb877baa 100644 --- a/gulp/aliases.js +++ b/gulp/aliases.js @@ -16,7 +16,7 @@ module.exports = (blueprint, gulp) => { gulp.task("compile", ["sass", "tsc", "copy"]); // generate docs data files - gulp.task("docs", ["docs-interfaces", "docs-kss", "docs-versions", "docs-releases"]); + gulp.task("docs", ["docs-json", "docs-versions", "docs-releases"]); // perform a full build of the code and then finish gulp.task("build", (done) => rs("clean", "compile", "bundle", "webpack-docs", done)); diff --git a/gulp/docs.js b/gulp/docs.js index 86d506d3d7..c3a2c12382 100644 --- a/gulp/docs.js +++ b/gulp/docs.js @@ -4,151 +4,47 @@ "use strict"; module.exports = (blueprint, gulp, plugins) => { + const dm = require("documentalist"); const glob = require("glob"); const path = require("path"); const text = require("./util/text"); - const tsdoc = require("ts-quick-docs"); const spawn = require("child_process").spawn; const semver = require("semver"); - const cwd = blueprint.findProject("docs").cwd; + const cwd = blueprint.findProject("docs-site").cwd; const config = { data: path.join(cwd, "src", "generated"), dest: path.join(cwd, "build"), - kssSources: blueprint.projectsWithBlock("sass").map((project) => path.join(project.cwd, "src")), + navPage: "_nav", }; // paths to data files used to generate documentation app const filenames = { - docs: "docs.json", - props: "props.json", + data: "docs.json", releases: "releases.json", - styleguide: path.join(cwd, "src", "styleguide.md"), versions: "versions.json", }; - const unwrapData = (section) => section.data; - - function processSection(section) { - return Object.assign({}, section, { - description: text.markdown(section.description), - highlightedMarkup: text.highlight(section.markup, "text.html.handlebars"), - modifiers: section.modifiers.map(unwrapData), - parameters: section.parameters.map(unwrapData), - sections: new Map(), - }); - } - - // find all flags: @[flag-name] [value?] - const FLAG_REGEX = /
@([\w-]+)(?:\s(.+))?<\/p>/g;
- function processFlags(section) {
- if (typeof section.description === "string") {
- section.description = section.description.replace(FLAG_REGEX, function (m, flag, value) {
- switch (flag) {
- case "interface":
- section.interfaceName = value;
- break;
- case "hide-markup":
- section.hideMarkup = true;
- break;
- case "react-docs":
- section.reactDocs = value;
- break;
- case "react-example":
- section.reactExample = value;
- break;
- case "angular-example":
- section.angularExample = value;
- break;
- default:
- break;
- }
- // remove flag from output
- return "";
- });
- }
- return section;
- }
-
- let parentsStack = [];
- /**
- * Convert a flat array of pages to a nested structure. Repeated references will overwrite previous instances.
- * Keeps a stack of parent sections so every new section can be added to its parent.
- * @param {Map Right-click on node or background. ` elements by default don't add any styles; they just inherit the base typography.
-This is a conservative design; ` ` elements are so ubiquitous that they're more often used for UI
-text than long form text. It's up to the user to decide which blocks of text in an application
-should get running text styles.
-
Markup:
-
- Default paragraphs have base typography styles.
-
- Running text is larger and more spaced out.
- Longform text, such as rendered Markdown documents, benefit from additional spacing and slightly
+large font size. Apply And another paragraph.
@@ -344,9 +281,7 @@ Markup:
@@ -483,26 +396,13 @@ Markup:
מתן החלל מאמרשיחהצפה ב. הספרות אנציקלופדיה אם זכר, על שימושי שימושיים תאולוגיה עזה
` for
-text, ` tag.
// must provide full TextMate language scope: "text.html.basic"
-function highlight(textContent, scopeName) {
- if (textContent) {
- return highlighter.highlightSync({
- fileContents: textContent,
- scopeName: scopeName ? scopeName : DEFAULT_SCOPE,
- });
+function highlight(fileContents, scopeName = DEFAULT_SCOPE) {
+ if (fileContents) {
+ return highlighter.highlightSync({ fileContents, scopeName });
}
}
@@ -64,4 +61,6 @@ module.exports = {
// render the given text as markdown, using the custom rendering logic above.
// code blocks are highlighted using highlight() above.
markdown: (textContent) => marked(textContent, { renderer }),
+
+ renderer,
};
diff --git a/gulp/watch.js b/gulp/watch.js
index ce8cfd5be4..1a5386a562 100644
--- a/gulp/watch.js
+++ b/gulp/watch.js
@@ -24,8 +24,8 @@ module.exports = (blueprint, gulp, plugins) => {
gulp.task("watch-files", ["connect"], () => {
blueprint.projectsWithBlock("sass").forEach((project) => {
const tasks = [`sass-${project.id}:only`];
- if (project.id !== "docs") {
- tasks.push("sass-variables", "docs-kss");
+ if (project.id === "core") {
+ tasks.push("sass-variables");
}
gulp.watch(createSrcGlob(project, "*.scss"), tasks);
});
@@ -34,11 +34,10 @@ module.exports = (blueprint, gulp, plugins) => {
gulp.watch(createSrcGlob(project, "*.ts{,x}"), [`tsc-${project.id}:only`]);
});
- const docsCwd = blueprint.findProject("docs").cwd;
- gulp.watch(`${docsCwd}/src/styleguide.md`, ["docs-kss"]);
+ gulp.watch("packages/*/!(node_modules)/**/*.md", ["docs-json"]);
- // recompile docs CSS when non-docs dist/*.css files change
- gulp.watch("packages/!(docs)/dist/*.css", ["sass-docs:only"]);
+ // recompile docs CSS when non-docs-site dist/*.css files change
+ gulp.watch("packages/!(docs-site)/dist/*.css", ["sass-docs-site:only"]);
});
gulp.task("watch", ["watch-files", "webpack-docs-watch"]);
diff --git a/gulp/webpack.js b/gulp/webpack.js
index df4672448c..6a3dd07bb9 100644
--- a/gulp/webpack.js
+++ b/gulp/webpack.js
@@ -7,7 +7,7 @@ module.exports = (blueprint, gulp) => {
const webpack = require("webpack");
const webpackConfig = require("./util/webpack-config");
- const docsProject = blueprint.findProject("docs");
+ const docsProject = blueprint.findProject("docs-site");
const configuration = webpackConfig.generateWebpackTypescriptConfig(docsProject);
gulp.task("webpack-docs", ["docs"], (callback) => {
diff --git a/mdify.js b/mdify.js
new file mode 100644
index 0000000000..a65cec3094
--- /dev/null
+++ b/mdify.js
@@ -0,0 +1,30 @@
+#!/usr/bin/env node
+
+const glob = require("glob");
+const fs = require("fs");
+
+// captures: [title, body, reference]
+const BLOCK_REGEX = /\/\*\n(.+)\n\n((?:.|\n)+?)\nStyleguide:? (.+)\n\*\//g;
+
+const HEADINGS = "######";
+
+glob.sync("packages/core/src/components/*/*.scss")
+ .filter((filepath) => !/common\.scss$/.test(filepath))
+ .forEach((comp) => {
+ const scss = fs.readFileSync(comp, "utf-8").replace(/^ */gm, "");
+ const contents = [`---\nparent: ${comp.indexOf("/forms/") > 0 ? "forms" : "components"}\n---`];
+
+ /** @type {RegExpExecArray} */
+ let match;
+ // tslint:disable-next-line:no-conditional-assignment
+ while ((match = BLOCK_REGEX.exec(scss)) !== null) {
+ const [title, body, reference] = match.slice(1);
+ const depth = reference.split(".").length - 1;
+
+ contents.push(
+ `${HEADINGS.slice(0, depth)} ${title}`,
+ body.trim().replace(/@\w+(-\w+)/g, (tag, ext) => tag.replace(ext, ext[1].toUpperCase() + ext.slice(2)))
+ );
+ }
+ fs.writeFileSync(comp.replace(".scss", ".md").replace("/_", "/"), contents.join("\n\n") + "\n");
+ });
diff --git a/package.json b/package.json
index 9bb783c9ec..951246990a 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,7 @@
"better-handlebars": "github:wmeldon/better-handlebars",
"chai": "3.5.0",
"del": "2.2.2",
+ "documentalist": "0.0.6",
"enzyme": "2.6.0",
"gulp": "3.9.1",
"gulp-concat": "2.6.0",
@@ -69,7 +70,6 @@
"karma-sinon": "1.0.5",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "1.8.0",
- "kss": "2.4.0",
"language-less": "github:atom/language-less",
"language-typescript": "github:giladgray/language-typescript#10.1.15",
"lerna": "2.0.0-beta.30",
diff --git a/packages/core/examples/alertExample.tsx b/packages/core/examples/alertExample.tsx
index c4e981a7fa..25d66e1d4f 100644
--- a/packages/core/examples/alertExample.tsx
+++ b/packages/core/examples/alertExample.tsx
@@ -8,7 +8,7 @@
import * as React from "react";
import { Alert, Button, Intent, IToaster, Toaster } from "@blueprintjs/core";
-import BaseExample from "./common/baseExample";
+import { BaseExample } from "@blueprintjs/docs";
export interface IAlertExampleState {
isOpen?: boolean;
diff --git a/packages/core/examples/buttonsExample.tsx b/packages/core/examples/buttonsExample.tsx
index 7ffb9d7593..0ecd8fce28 100644
--- a/packages/core/examples/buttonsExample.tsx
+++ b/packages/core/examples/buttonsExample.tsx
@@ -9,7 +9,7 @@ import * as classNames from "classnames";
import * as React from "react";
import { AnchorButton, Button, Classes, Intent, Switch } from "@blueprintjs/core";
-import BaseExample, { handleBooleanChange, handleNumberChange } from "./common/baseExample";
+import { BaseExample, handleBooleanChange, handleNumberChange } from "@blueprintjs/docs";
import { IntentSelect } from "./common/intentSelect";
export interface IButtonsExampleState {
diff --git a/packages/core/examples/collapseExample.tsx b/packages/core/examples/collapseExample.tsx
index e514ebc000..2d8b6bf3d7 100644
--- a/packages/core/examples/collapseExample.tsx
+++ b/packages/core/examples/collapseExample.tsx
@@ -8,7 +8,7 @@
import * as React from "react";
import { Button, Collapse } from "@blueprintjs/core";
-import BaseExample from "./common/baseExample";
+import { BaseExample } from "@blueprintjs/docs";
export class CollapseExample extends BaseExample<{ isOpen: boolean }> {
public state = {
diff --git a/packages/core/examples/collapsibleListExample.tsx b/packages/core/examples/collapsibleListExample.tsx
index 742758e0b6..001855b392 100644
--- a/packages/core/examples/collapsibleListExample.tsx
+++ b/packages/core/examples/collapsibleListExample.tsx
@@ -17,7 +17,7 @@ import {
RadioGroup,
Slider,
} from "@blueprintjs/core";
-import BaseExample, { handleNumberChange } from "./common/baseExample";
+import { BaseExample, handleNumberChange } from "@blueprintjs/docs";
export interface ICollapsibleListExampleState {
collapseFrom?: CollapseFrom;
diff --git a/packages/core/examples/contextMenuExample.tsx b/packages/core/examples/contextMenuExample.tsx
index 7c8d83bbe7..ba163b64e6 100644
--- a/packages/core/examples/contextMenuExample.tsx
+++ b/packages/core/examples/contextMenuExample.tsx
@@ -12,7 +12,7 @@ import * as PureRender from "pure-render-decorator";
import * as React from "react";
import { ContextMenu, ContextMenuTarget, Menu, MenuDivider, MenuItem } from "@blueprintjs/core";
-import BaseExample from "./common/baseExample";
+import { BaseExample } from "@blueprintjs/docs";
/**
* This component uses the imperative ContextMenu API.
@@ -52,15 +52,7 @@ class GraphNode extends React.Component<{}, { isContextMenuOpen: boolean }> {
*/
@ContextMenuTarget
export class ContextMenuExample extends BaseExample<{}> {
- public renderExample() {
- return (
-
H5 heading
H6 heading
-Weight: 3
-
-Styleguide typography.headings
+Styleguide headings
*/
$headers: (
@@ -117,20 +84,13 @@ $headers: (
/*
UI text
-The base font size for Blueprint web applications is 14px. This should be the default type size
-for most short strings of text which are not headings or titles. If you wish to reset some
-element's font size and line height to the default base styles, use the `.pt-ui-text` class.
-For longer running text, see [running text styles](#typography.running-text).
-
Markup:
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
- labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
- nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
- esse cillum dolore eu fugiat nulla pariatur.
-
- Excepteur sint occaecat cupidatat non proident.
-.pt-running-text
to the parent element to adjust spacing for the following
+elements:
+
+ <p>
tags have increased line-height and font size.<h*>
tag margins are adjusted to provide clear separation between sections in a document.<ul>
and <ol>
tags receive [`.pt-list`](#typography.lists) styles for legibility.New section
+ ` for code blocks, and `
-Weight: 6
-
-Styleguide typography.preformatted
+Styleguide preformatted
*/
pre,
@@ -326,8 +265,6 @@ pre {
/*
Block quotes
-Block quotes are treated as running text.
-
Markup:
` for inline code. Note that `
` blocks will
-retain _all_ whitespace so you'll have to format the content accordingly.
-
Markup:
$ npm install
@@ -264,9 +205,7 @@ Markup:
});
}
-Weight: 7
-
-Styleguide typography.blockquotes
+Styleguide blockquote
*/
blockquote {
@@ -367,11 +302,6 @@ blockquote {
/*
Lists
-Blueprint provides a small amount of global styling and a few modifier classes for list elements.
-
-`` and `
` elements in blocks with the `.pt-running-text` modifier class will
-automatically assume the `.pt-list` styles to promote readability.
-
Markup:
Arabic:
` for code, etc.). The following variables are provided for the
-rare cases where custom styling is necessary and should be used sparingly:
-
-- `$pt-font-family`
-- `$pt-font-family-monospace`
-- `$pt-font-size`
-- `$pt-font-size-small`
-- `$pt-font-size-large`
-- `$pt-line-height`
-
-See the [Fonts section](#typography.fonts) for more information and usage guidelines.
-
-Styleguide variables.fonts
-*/
-
// see https://bitsofco.de/the-new-system-font-stack/
$pt-font-family: -apple-system,
"BlinkMacSystemFont",
@@ -68,28 +32,7 @@ $pt-font-size-small: $pt-grid-size * 1.2 !default;
// a little bit extra to ensure the height comes out to just over 18px (and browser rounds to 18px)
$pt-line-height: ($pt-grid-size * 1.8) / $pt-font-size + 0.0001 !default;
-/*
-Icon variables
-
-Most icons should be displayed using the `span.pt-icon-*` classes or via modifier classes on
-components like `.pt-button`. In rare cases, you may need direct access to the content
-string that generates each icon in the icon font. Blueprint provides these variables with
-straightforward names (see the [Icons section](#icons) for the full list of identifiers):
-
-- `$pt-icon-style`
-- `$pt-icon-align-left`
-- `$pt-icon-align-center`
-- ...
-
-Variables are also provided for the two icon font families and their pixel sizes:
-
-- `@icons16-family`
-- `@icons20-family`
-- `$pt-icon-size-standard`
-- `$pt-icon-size-large`
-
-Styleguide variables.icons
-*/
+// Icon variables
$icons16-family: "Icons16" !default;
$icons20-family: "Icons20" !default;
@@ -97,24 +40,7 @@ $icons20-family: "Icons20" !default;
$pt-icon-size-standard: 16px !default;
$pt-icon-size-large: 20px !default;
-/*
-Grids & dimensions
-
-Sizes of common components. Most sizing variables are based on `$pt-grid-size`, which has
-a value of `10px`. Custom components should adhere to the relevant `height` variable.
-
-- `$pt-grid-size`
-- `$pt-border-radius`
-- `$pt-button-height`
-- `$pt-button-height-large`
-- `$pt-input-height`
-- `$pt-input-height-large`
-- `$pt-navbar-height`
-
-Weight: 1
-
-Styleguide variables.dimensions
-*/
+// Grids & dimensions
$pt-border-radius: floor($pt-grid-size / 3) !default;
@@ -129,40 +55,6 @@ $pt-input-height-large: $pt-grid-size * 4 !default;
// Others
$pt-navbar-height: $pt-grid-size * 5 !default;
-/*
-Grid system
-
-Blueprint doesn't provide a grid system. In general, you should try to use the `$pt-grid-size`
-variable to generate layout & sizing style rules in your CSS codebase.
-
-In lieu of a full grid system, you should try to use the __CSS flexible box layout model__ (a.k.a.
-"flexbox"). It's quite powerful on its own and allows you to build robust, responsive layouts
-without writing much CSS. Here are some resources for learning flexbox:
- - [MDN guide](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes)
- - [CSS Tricks guide](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)
-
-Styleguide variables.dimensions.grid
-*/
-
-/*
-Layering
-
-Blueprint provides variables for three z-index layers. This should be enough for most use cases,
-especially if you make correct use of [stacking context][MDN]. [Overlay](#components.overlay)
-components such as dialogs and popovers use these z-index values to configure their stacking
-contexts.
-
-- `$pt-z-index-base`
-- `$pt-z-index-content`
-- `$pt-z-index-overlay`
-
-[MDN]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
-
-Weight: 1
-
-Styleguide variables.layering
-*/
-
// Z-indices
$pt-z-index-base: 0 !default;
$pt-z-index-content: $pt-z-index-base + 10 !default;
@@ -206,21 +98,7 @@ $pt-transition-ease: cubic-bezier(0.4, 1, 0.75, 0.9) !default;
$pt-transition-ease-bounce: cubic-bezier(0.54, 1.12, 0.38, 1.11) !default;
$pt-transition-duration: 100ms !default;
-/*
-Light theme styles
-
-Use these when you need to build custom UI components that look similar to Blueprint's
-light theme components.
-
-- `$pt-dialog-box-shadow`
-- `$pt-input-box-shadow`
-- `$pt-popover-box-shadow`
-- `$pt-tooltip-box-shadow`
-
-Weight: 2
-
-Styleguide variables.light
-*/
+// Light theme styles
$pt-input-box-shadow: inset border-shadow(0.15),
inset 0 1px 1px rgba($black, $pt-drop-shadow-opacity) !default;
@@ -229,21 +107,7 @@ $pt-dialog-box-shadow: $pt-elevation-shadow-4 !default;
$pt-popover-box-shadow: $pt-elevation-shadow-3 !default;
$pt-tooltip-box-shadow: $pt-popover-box-shadow !default;
-/*
-Dark theme styles
-
-Use these when you need to build custom UI components that look similar to Blueprint's
-dark theme components.
-
-- `$pt-dark-dialog-box-shadow`
-- `$pt-dark-input-box-shadow`
-- `$pt-dark-popover-box-shadow`
-- `$pt-dark-tooltip-box-shadow`
-
-Weight: 3
-
-Styleguide variables.dark
-*/
+// Dark theme styles
$pt-dark-input-box-shadow: inset border-shadow(0.3),
inset 0 1px 1px rgba($black, $pt-dark-drop-shadow-opacity) !default;
diff --git a/packages/core/src/components/_index.scss b/packages/core/src/components/_index.scss
index 650c3b3db2..994565cac0 100644
--- a/packages/core/src/components/_index.scss
+++ b/packages/core/src/components/_index.scss
@@ -3,211 +3,6 @@
// of the license at https://github.com/palantir/blueprint/blob/master/LICENSE
// and https://github.com/palantir/blueprint/blob/master/PATENTS
-/*
-Components
-
-Blueprint's JavaScript components are stable and their APIs adhere to
-[semantic versioning](http://semver.org/).
-They are distributed in the __@blueprintjs/core__ package and can be consumed as CommonJS modules
-[via NPM](https://www.npmjs.com/package/@blueprintjs/core).
-
-Weight: 6
-
-Styleguide components
-*/
-
-/*
-Usage
-
-Weight: -1
-
-Styleguide components.usage
-*/
-
-/*
-NPM installation
-
-1. Install the core package with an NPM client like `npm` or `yarn`, pulling in all relevant
-dependencies:
-
- ```sh
- npm install --save @blueprintjs/core
- ```
-
-1. If you see `UNMET PEER DEPENDENCY` errors, you should manually install React:
-
- ```sh
- npm install --save react react-dom react-addons-css-transition-group
- ```
-
-1. After installation, you'll be able to import the React components in your application:
-
- ```
- // extract specific components
- import { Intent, Spinner, DatePickerFactory } from "@blueprintjs/core";
- // or just take everything!
- import * as Blueprint from "@blueprintjs/core";
-
- // using JSX:
- const mySpinner =