React Doc Starter
website·Indexed 29 days ago
https://samonxian.github.io/react-doc-starter/A documentation starter kit based on Docusaurus 2 designed for teams to document business components and utility libraries. It provides a solution for developing and showcasing React component libraries (based on antd 4.3.3+) and utility functions, featuring built-in components like PropsTable, CodeShow, and TsDoc to streamline the documentation process.
What's inside React Doc Starter
- React Doc Starter is a development solution based on Docusaurus 2, optimized for teams to document internal business components and utility libraries. It uses Vite for bundling and requires Node.js version >= v16. Note: Automated documentation generation currently does not support internationalization (i18n); for i18n scenarios, documentation must be written manually following Docusaurus standards.
Overview of React Doc Starter
React Doc Starter is a development solution based on Docusaurus 2 designed for teams to document internal business components and utility libraries. It streamlines the process by providing integrated bundling via Vite and automated documentation generation from code comments.
Requirements: Node.js version >= v16. Limitation: Automated documentation generation via comments does not currently support internationalization (i18n); manual documentation is required for those scenarios.
Overview of React Doc Starter
React Doc Starter is a solution based on Docusaurus 2 tailored for teams to document internal business components and utility libraries. It streamlines the development process by integrating Vite for bundling and providing specialized MDX components to automate documentation from source code.
Requirements: Node.js version >= v16. Limitation: Automated documentation generation via comments does not currently support internationalization (i18n); for i18n, documentation must be written manually following Docusaurus standards.
Overview of the customized Table component
The Table component is a wrapper around the Ant Design (Antd) Table with several enhancements: columns withfixedproperties do not need to be defined in order, empty data (null/undefined) is displayed as a placeholder character by default, columns can be hidden via configuration, and data does not wrap by default.Manage content visibility with ProContent status tips
TheProContentcomponent is used to wrap content and conditionally display status prompts. If any status tip is enabled, the child components will not be rendered. The display priority for these tips is as follows: Error Tip > Warning Tip > Success Tip > No Data Tip > Search Tip.Extend and customize the documentation site with React
Because the site is built with React, developers can implement extensions and customizations by providing their own React components to fully control the browsing experience.Develop and build React Doc Starter locally
To run the documentation site locally or build it for production, navigate to thewebsitedirectory within the project.# Local Development git clone https://github.com/samonxian/react-doc-starter.git cd ./website npm start # Access via http://localhost:3000/ # Production Build cd ./website npm run build # Static content is generated in the /build directoryDeploy React Doc Starter to GitHub Pages
The starter provides a convenient deployment command that builds the site and pushes it to thegh-pagesbranch. Run this from thewebsitedirectory.# Using SSH cd ./website USE_SSH=true npm run deploy # Without SSH cd ./website GIT_USER=<your-github-username> npm run deployCreate and manage fullscreen mode with createFullscreen
ThecreateFullscreenutility provides a cross-browser compatible way to trigger and manage fullscreen mode for a specific DOM element. It handles the various browser-specific implementations of the Fullscreen API. When using this in React components, it is recommended to use theuseFullScreenhook instead. To prevent memory leaks or duplicate event bindings, always call theremove()method to clear previous listeners before creating a new binding or within a component's cleanup/destroy hook.const fullscreenObj = createFullscreen( targetDOM, targetDOM.ownerDocument || document, () => { const isFull = !!fullscreenObj.fullscreenElement; if (!isFull) { // Not in fullscreen, remove the listener fullscreenObj.remove(); } } ); if (fullscreenObj.isDomFullscreenSupported) { const isFull = !!fullscreenObj.fullscreenElement; if (!isFull) { fullscreenObj.requestFullscreen(); } else { fullscreenObj.exitFullscreen(); } } else { // Handle unsupported browser }Install react-antd-business-components
Install the business components library using npm. Note that these components are based on Ant Design (antd) and require antd version 4.3.3 or higher to function correctly.npm i react-antd-business-componentsDevelop and deploy React Doc Starter locally
Follow these steps to set up the development environment, build the static site, and deploy to GitHub Pages.# Local Development git clone https://github.com/samonxian/react-doc-starter.git cd ./website npm start # Access at http://localhost:3000/ # Build Static Site cd ./website npm run build # Output is generated in the /build directory # Deploy to GitHub Pages (via SSH) cd ./website USE_SSH=true npm run deploy # Deploy to GitHub Pages (without SSH) cd ./website GIT_USER=<your-github-username> npm run deployUse specialized components for React and Utils documentation
The react-doc-starter provides a unified way to display business components and utility library documentation. Most documentation scenarios can be handled using three primary components:PropsTable,CodeShow, andTsDoc.