docs/README-EDITING.md
This page covers guidelines for editing the Handsontable documentation.
When adding new documentation files, check the documentation directory structure, and follow the guidelines below.
-..md file extension.Each Markdown file can start with the following frontmatter tags:
| Tag | Meaning | Default value |
|---|---|---|
id | The page's unique ID. | Required. Used for redirecting between different versions (e.g., 12.1 to 11.0) of the same documentation page (https://github.com/handsontable/handsontable/pull/10163). Don't change the IDs of existing pages. To add an ID for a new page, generate 8 random alphanumeric characters (https://www.random.org/strings/?num=20&len=8&digits=on&loweralpha=on&unique=on&format=html&rnd=new). |
title | The page's header. | If not set, gets generated from the page's parent's title. |
permalink | The page's unique URL. | If not set, gets generated from the Markdown file name. |
canonicalUrl | A canonical URL of the page's latest version. | None (not required) |
metaTitle | The page's SEO meta title. | None (not required) |
description | The page's SEO meta description. | None (not required) |
tags | Search tags used by the documentation search engine. | None (not required) |
react | Holds an alternative set of frontmatter tags (applied only to the React version of the page) | None (not required) |
angular | Holds an alternative set of frontmatter tags (applied only to the Angular version of the page) | None (not required) |
searchCategory | Search category used by the search engine to categorize the search results. | If not set, the search result will be listed under the default "Guides" section. |
menuTag | A tag displayed next to the page title in the sidebar menu. | None (not required) |
category | The content category for organizing pages. | None (not required) |
You can set different frontmatter tags for different framework versions of the page. For example, you can set metaTitle to say either JS data grid or React data table, depending on the framework:
```yaml // applies to the JS version of the page metaTitle: JS data grid
// applies to the React version of the page react: metaTitle: React data table
// applies to the Angular version of the page angular: metaTitle: Angular data table ```
You can use the following framework keys:
reactangularFrontmatter example:
---
id: 1ezrscdc
title: Introduction
metaTitle: Installation - Guide - Handsontable Documentation for Javascript
description: Easily install the data grid using your preferred package manager or import Handsontable assets directly from the CDN.
permalink: /api/
canonicalUrl: /api/
react:
id: xyr8fg2e # The page id should be different for different for other framework variations
metaTitle: Installation - Guide - Handsontable Documentation for React
description: Install the wrapper for React via npm, import stylesheets, and use it to get up and running your application.
customValue: Custom # Custom value that can be used within template and will be available only for React framework
angular:
id: abc12345
metaTitle: Installation - Guide - Handsontable Documentation for Angular
description: Install the wrapper for Angular via npm, import stylesheets, and use it to get up and running your application.
tags:
- api
- api ref
searchCategory: API Reference
---
When editing the documentation content, follow the guidelines below.
Note: Content
.mdfiles are cached by Astro's data store. After editing content files, you need to restart the dev server withnpm run dev -- --forceto see changes. CSS and JS changes are picked up by HMR automatically.
next documentation versionDraft files to be included in the documentation's next version are kept in the content directory.
The next version of the documentation is available only locally and on the staging server.
To display the next version in a browser:
To edit an already-published documentation version, go to the prod-docs/<MAJOR.MINOR> branch (e.g. prod-docs/9.0).
To display a published documentation version in a browser:
If you're editing the latest version (a version with the largest <MAJOR.MINOR> number), remember to make the same edits to the next version as well.
The next version's API reference is generated automatically from the source code, into the /content/api/ directory.
To edit the next version's API reference:
next version's API reference output:
npm run docs:api
To edit a published version's API reference:
/docs/<MAJOR.MINOR>/api (e.g. /docs/9.0/api).When reviewing someone else's changes, you can see the documentation output in a few different ways:
New documentation is created automatically after the Handsontable is released. The stable-publish job in .github/workflows/publish.yml creates or updates the documentation production branch, generates API content from source code, commits, and pushes - which then triggers the Netlify deployment.
When linking to other documentation pages, avoid using absolute links or relative URLs.
To link to another page in the same documentation version, use the following syntax:
[link_text](@/relative_file_path_from_this_version's_root/file_name.md#some-anchor)
For example, to link to a file called core.md, from anywhere in the same documentation version:
[Core](@/api/core.md#updatesettings)
To link to another page but for other framework (and still for the same documentation version), use the following syntax:
[link_text](@/{FRAMEWORK}/relative_file_path_from_this_version's_root/file_name.md#some-anchor)
For example, to link to a file called ./content/guides/getting-started/react-methods.md that should be accessible only for React framework, use:
[React methods](@/react/guides/getting-started/react-methods/react-methods.md)
When there is no framework defined in the link URL, the generated link will be pointed to the currently viewed framework. For example, link [Core](@/api/core.md) for Javascript will point to /docs/javascript-data-grid/api/core and for chosen React framework to /docs/react-data-grid/api/core.
List of available frameworks: javascript, react, angular.
Follow these rules:
@ character, provide the target's relative file path (from the current version's root directory).
For example: [Clipboard][@/guides/cell-features/clipboard/clipboard.md]..md extension.
For example: [Autofill](@/api/autofill.md).[Core](@/api/core.md#some-anchor).Also, the following rules apply:
permalink frontmatter tag defined.To render content in different ways, the documentation uses Markdown containers, for example:
::: example #exampleId .class :preset --html 1 --js 2
// code example
:::
We use the following Markdown containers:
| Container | Usage |
|---|---|
::: tip [title] | Adds a blue tip note. |
::: warning [title] | Adds a yellow warning note. |
::: danger [title] | Adds a red danger note. |
::: details [title] | Adds an accordion with expandable content. |
::: source-code-link <URL> | Adds a source code link to the API ref header. |
::: example [options] | Renders a code example as specified in [options]. |
These containers are processed by the vuepress-preprocessor.mjs plugin in src/plugins/, which converts the VuePress-style syntax into Astro/Starlight-compatible output.
For tip / warning / danger / note callouts, the body is not full CommonMark. The preprocessor turns inline `code`, **bold**, and [label](url) into HTML (see aside-inline-markdown.mjs).
Using the example Markdown container, you can add code snippets that show the code's result:
::: example #exampleId .class :react-redux --html 1 --js 2 --css 3 --no-edit --tab preview
```html
<div id="exampleId"></div>
```
```js
// code here
```
```css
/* custom css here */
```
:::
The example Markdown container offers the following options:
| Option | Required | Example | Possible values | Usage |
|---|---|---|---|---|
#exampleId | No | #example1 | String | Container's unique ID. |
.class | No | .new-class | String | Container's custom class. |
:preset | No | :hot | :hot | :hot-lang | :hot-numbro | :react | :react-languages | :react-numbro | :react-redux | :react-advanced | :angular | :angular-languages | :angular-numbro | :vue3 | :vue3-numbro | :vue3-languages | :vue3-vuex | Sets code dependencies. |
--js <pos> | No | --js 1 | Positive integer | |
(default 1) | Sets the JS code snippet's position | |||
| in the markdown container. | ||||
--html <pos> | No | --html 2 | Positive integer | |
(default 0) | Sets the HTML code snippet's position | |||
| in the markdown container. |
0 disables the HTML tab. |
| --css <pos> | No | --css 2 | Positive integer
(default 0) | Sets the CSS code snippet's position
in the markdown container.
0 disables the CSS tab. |
| --no-edit | No | --no-edit | --no-edit | Removes the Edit button. |
| --tab <tab> | No | --tab preview | code | html | css | preview | Sets a tab as open by default. |
You can also embed an example without the tabbed container.
To display just the result of the code you want to present, use the <HandsontablePreview> component. The code wrapped in this component and a markdown code block will be rendered with the context of the current Handsontable version.
<HandsontablePreview>
```js
// enter the Handsontable-related code here.
const containerElement = document.querySelector('#hot');
new Handsontable(containerElement, {});
Note: Remember to place all the needed HTML and <style> elements in the markdown file as well.
When you edit React examples and code samples, follow the guidelines below.
For matters not covered here, follow the conventions of https://beta.reactjs.org/learn.
settings={} prop. Instead, specify individual props.
<HotTable
data={data}
height="auto"
/>
""). If a prop's value is a string, use double quotes without curly braces.
licenseKey="00000-00000-00000-00000-00000"
''). For example, if a React prop contains a JS object:
<HotTable
licenseKey="00000-00000-00000-00000-00000"
nestedHeaders={[
['A', { label: 'B', colspan: 8 }, 'C']
]}
/>
<Fragment> with a single child).import { useRef } from 'react';
useRef(...);
Ref to that constant's name.
const hotRef = useRef(null);
const hotTableComponentRef = useRef(null);
useRef instead of React.createRef.<> shorthand instead of the explicit syntax (<React.Fragment>).
<>
<HotTable/>
<div className="controls">
// (...)
</div>
</>
data as a const, outside of JSX.
const data = [
['', 'Tesla', 'Volvo', 'Toyota', 'Ford'],
['2019', 10, 11, 12, 13],
['2020', 20, 11, 14, 13],
['2021', 30, 15, 12, 13]
];
return <HotTable data={data} />