- Node.js
- Docusaurus by Facebook / Meta
- GitHub
- AWS Amplify
-
System dependencies, common to most web development
- VS code, or similar editor
- Extension: Git Lens
- Extension: Prettier
- Extension: MDX
- Terminal configured to work with this GitHub repository
- Node.js is installed
- VS code, or similar editor
-
Clone this repository,
git clone https://github.com/clearpathrobotics/cpr-documentation.git
-
Open the folder
-
In a terminal, navigate to the root of the project folder and run
npm install
-
Pull the AWS configuration settings to your local machine by running
amplify pull --appId dfy90wyu8dics --envName staging`
This should open a tab in your web browser, asking for permission to connect Amplify Studio to the Amplify CLI (command line interface). After responding yes, return to the terminal and answer a few more questions to configure your local machine:
? Choose your default editor: Visual Studio Code ? Choose the type of app that you're building javascript ? What javascript framework are you using react ? Source Directory Path: . ? Distribution Directory Path: build ? Build Command: npm run build ? Start Command: npm run start ? Do you plan on modifying this backend? No
-
Start the local server by running
npm run start
-
A new tab should open in your prefered web browser once the site is running. Your terminal session should show the port the webpage is running on. The default address is http://localhost:3000/ but this may change if you are already using that port for another site.
-
If you want to test something on a mobile screensize; you can do this within your desktop's Chrome browser. When the site is running locally; enter Chrome's developer tools by selecting: 3 dots in the top right → More tools → Developer tools. You can then select the Device Toolbar button, and change the screensize, as shown in the two images below. We are designing to a smallest screen width of 320 px.
-
Clone or fork this repository,
git clone https://github.com/clearpathrobotics/cpr-documentation.git`
-
Create a branch from development. with a name indicating the purpose, such as feature_xxxxxx
-
Make changes to the relevant files
-
Test using your local server, using the steps mentioned Steps to run this on your computer locally
-
When ready, enter
ctrl-c
in your terminal to stop the server. Then runnpm run build
to test that the site builds corretly. -
Resolve any errors that the terminal reports, and rerun the command
npm run build
. -
Finally, check that your updates adhere to our code formatting standard, by running the command
npm run format-check
. The terminal will either report:- All matched files use Prettier code style!
- Code style issues found in the above file(s). Forgot to run Prettier?
You can fix the errors by running the command
npm run format-write
. This format all the files in the repository, and save them automatically.- Refer to the package.json to understand what this script calls.
- Refer to the .prettierrc.json to understand the rules Prettier is using when checking files.
- Alternativaly, you can format a single file by running
npx prettier --write <FILE PATH>
, such asnpx prettier --write README.md
-
You will need to confirm that
npm run format-write
code formatting did not make any functionality changes to your .mdx documentation. You may see files that claim to be updated in Source Control, but don't have any visible changes. You should run these commands in your terminal to prevent Git from noting these types of changes:git config --global core.filemode false git config --global core.autocrlf false
-
When ready, publish your branch on GitHub, and submit a Pull Request to merge your changes into the development branch. Pull Requests to the production branch will not merged. Also note that this GitHub repository has branch protection rules, that prevent you from committing directly to production and development.
-
The administrators of this documentation will review the website for any functional issues, and will periodically merge the latest commits in the development branch into the production branch.
The OutdoorNav User Manual is a "versioned" document, which means that a snapshot of the content is made to align with a release. This allows users to access version-specific copies of the documentation.
During the development phase, follow steps 1-10 of the workflow above. Note that the updates will not affect the default view of the user manual, only the "next" version of the manual (eg. http://docs.clearpathrobotics.com/docs_outdoornav_user_manual/next/index).
When it is time to publish a numbered release of the user manual:
-
Create a branch from development with a name indicating the purpose, such as release_xxxxxx
-
Run the versioning command, where new_version is aligned with the corresponding software release:
npm run docusaurus docs:version:outdoornav_user_manual <new_version>
-
Update /docs/software/navigation_packages.mdx to:
- Update the version number for the "Latest".
- Add an entry for the previous release.
-
Update /static/versions.js to update the outdoornav version to match the GitHub tag.
-
Build and test the changes (see steps 4-8 from the standard workflow above).
-
When ready, publish your branch on GitHub, and submit a Pull Request to merge your changes into the development branch. Be sure to include the updates to the following:
- outdoornav_user_manual_versioned_docs/
- outdoornav_user_manual_versioned_sidebars/
- outdoornav_user_manual_versions.json
Follow the steps for the OutdoorNav User Manual workflow above, replacing outdoornav with indoornav.
- Refer to Markdown's guide for syntax
- Refer to Docusaurus's guide for supported Markdown features
- For advanced users, refer to Markdown MDX for adding React Components to a Markdown file
- for advanced users, you may create React pages using .js or .ts file types
All files should use lowercase letters for their names and file extensions. Our website's server is case sensitive, so it requires files case to match how it is called in your Markdown files. Your Windows build commands may not catch these issues since Windows is not case sensitive. Using lowercase letters minimizes the number of build issues.
- Good:
controller_1.png
- Bad:
Controller_1.png
- Bad:
controller_1.PNG
Downloadable assets like PDFs should say clearpath_robotics at the start of the name. This helps User's know where they downloaded the file from later, as the asset is saved to their Downloads folder.
-
Markdown page
/docs
-
Markdown component, like a section to be reused in multiple pages
/components
-
Images
/static/img
-
PDFs and similar customer facing files
/static/assets
We have this site deployed on AWS Amplify. Their server is monitoring the production and development branches of this repository. When AWS sees a new commit on either branch, it will rebuild the site. The image below shows the development branch rebuilding after the GitHub branch was updated by a Pull Request.
This example took 2 minutes and 14 seconds to deploy. If your feature branch change is large, we can deploy it as a temporary site on AWS to confirm that it builds before submitting a Pull Request into Development. The downsides of deploying more branches are:
- Possible time lost, though this may save time by preventing build errors on the production branch
- A small cost to AWS for using their Server. At the time of writing (May 2022), AWS charges $0.01 USD per build minute.
You can find templates in the directory /static/reference_pages
You can add equations using KaTex syntax. The packages have are installed in the package.json and imported into the project in docusaurus.config.js. You simply need to add your equations to your Markdown file, keeping all the elements between opening an closing tags $.
You can test equation syntax using this tool from KaTex.
We want images to convey information. The best way to do this is to have a consistent method notating images, and removing unnecessary content. The list below are not strict rules, but are considered good practice to keep images throughout the site looking consistent,
-
Highlight colours should be:
- Primary
- #BB0000
- RGB (187, 0, 0)
- Secondary
- #00C7A6
- RGB (0, 199, 166)
- Tertiary
- #4E7FFF
- RGB (78, 127, 255)
- Primary
-
Remove background colours when possible. This helps Users that have set the site to Dark Mode. Refer to SolidWorks image exports for the process of creating these images.
-
Avoid embedding text in images. This prevents Users from translating the webpage. Consider using arrows and circles to notate images, with the text included in your Markdown file.
Note: icons, logos, and symbols that are part of the physical product are exempt from this suggestion.
-
Open your assembly in SolidWorks. Orient the model to the view you want to capture. Click File → Save-As.
-
Select .png as the file type. Then click the Options button.
-
Make sure the Remove background box has a check mark. Click the Print capture box, so you can manually choose the image's width and height.
-
In the same window as Step 3; scroll down to the bottom. Change the Width and Height fields to adjust the bounding box around the SolidWorks model. 300 mm tall should be a good balance between image resolution and file size.
Finally, select OK, and Save
Our website uses AWS Authenticator to allow a user to login. We have intentionally removed the fields to allow a user to sign up, since we intend to manage access by invitation only. To login, the user clicks the Sign In button at the bottom of the page, and enters their username and password.
Most of the functionality is added in this repository's file /src/theme/Root.js
.
Root.js is Docusaurus's way to change application functionality, similar to App.js in a standard React application.
In Root.js's return section, <Authenticator>
may be added to the DOM, based on some binary State checks.
When <Authenticator>
is added to the DOM, a popup will appear in the centre of the user's screen, asking for login credentials.
Authenticator is a user interface component.
The actual sign in and getting user information from the AWS database is done with Auth
.
Root.js is configured to get database configuration details using:
import awsExports from '/aws-exports';
Once the user has signed in, we use methods from Auth
to review the user's infromation stored in the database.
The main thing that we are checking is what groups
the user is assigned to.
How a user gets routed to hidden content
Authenticator
and Auth
handle the login.
We then use our components BlockedPageRouting
and InjectPrivilegedContent
to decide what gets pushed to the DOM.
You can find these components in /components_hidden/authentication
.
You can see these components being used on the page /docs/tools/documentation
.
Where to put hidden source files
Content that you want to hide should either be placed in:
docs_hidden
for full pages. Note that these are Docusaurus Pages, rather than Docusaurus Docs. The main differences being that Pages do not get built into a tree structure, and do not have a table-of-contents.components_hidden
for snippets of content, to call into an existing page.- Images go in the standard location
/static/img
. Images were not considered sensitive during the development of these authentication tools. This means users can access any image through a URL, even if they are not logged in. For example: https://docs.clearpathrobotics.com/img/robot_images/husky_images/husky_banner.png
Anything in docs_hidden
will need a 2 file structure, similar to the examples in /docs_hidden/hiddenPageExample
.
This 2 file structure is required by our BlockedPageRouting
component, to prevent unpriviliged users from accessing the data through their browser's developer tools.
aws-exports
is a file that gets created during the Docusaurus build.
This file includes database configuration details which are necessary for Auth
to connect to the AWS database.
It is important that aws-exports.js
does not get shared publicily, since this would allow someone to access our user data.
- Keep
aws-exports.js
in the.gitignore
file - Do not run
amplify pull
on a local server that is being shipped to a customer (like a robot).amplify pull
should only be run on our development computers, when we intend to make changes to this repository. - Do not publish the contents of
aws-exports.js
publicly (emails, GitHub comments, Support tickets).
-
Login to AWS.
-
Confirm that you are connected to the Ohio datacenter.
-
Select the Cognito application (you may need to use the serch bar).
-
Select the link for the
cprdocumentation-staging
data. -
Select the Create user button.
-
Fill in the user's information, and then select the Create user button.
-
You will be routed back to the Cognito homepage. Find the new entry in the Users list, and click on the hyperlink for that new user.