permalink | title |
---|---|
/wr_validationtools |
Validating documentation |
Producing documentation requires patience and diligence because the work can become tedious. Writers often make small mistakes such as mispelling a word or filename. When you mispell a filename, the link is considered broken. Review the following sections to learn how to validate documentation:
{: #md}
Markdown has a few tools to help you validate that you are producing error-free files, such as the Link checking tool,Spellcheck tool, and Local build tool.
Prerequisite: Before you begin, you must download NPM for your operating system.
-
If you are a MacOS user, complete the following steps to install NPM:
-
Install Xcode from the Apple Store.
-
Install Homebrew from your Terminal by running the following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
{: codeblock}
-
Install NPM from your Terminal by running the following command:
brew install node
{: codeblock}
-
-
If you are a Windows user, complete the following steps to install NPM:
- After you download the install, double-click the installer and complete the instructions that are provided.
Note: You can use the default settings. If you encounter problems, you can use the package installer and follow the instructions on the NodeJS site.
-
Verify that NodeJS and NPM are installed by running the following commands:
node -v npm -v
{: codeblock}
You are now ready to validate your documentation.
Install the Markdown broken link tool to extract links from markdown files.
Install and run the broken link tool from your terminal by completing the following steps:
-
Install the link check tool from the command-line interface (CLI) by running the following command:
npm install -g markdown-link-check
{: codeblock}
-
On your local drive, navigate to the directory where the
docs
repository is cloned. Run the following command:cd ~/Documents/docs
{: codeblock}
-
Run the link check tool on the
docs
repository. To create a text file of your results from the tool, run the following command:find . -name "*.md" -exec markdown-link-check -q {} \; > ../filename.txt
{: codeblock}
-
Open the text file that has the broken link results by navigating to the file with the Finder application.
Tips: You may encounter the following results in your text file:
FILE: ./manage_cluster/create_storage_class.md
[✖] ../manage_cluster/create_vfd_vol.md
FILE: ./manage_cluster/ma_adv.md
[✖] ../../images/icons/launch-glyph.svg
FILE: ./supported_system_config/hardware_reqs.md
[✖] ../../supported_environments/edge/install_edge.md#prereq_hard
FILE: ./apis/mcm/mt_mcm_apis.md
[✖] ../../../manage_cluster/cluster_endpoints.md#master
[✖] ../../..//apis/cfc_api_files/directory_mgmt.md#list
{: codeblock}
- Remember, icons are considered to be internal links. Be sure to use the Preview feature view in Visiual Studio Code (or another text editor), or select the Preview changes tab in GitHub from the browser.
- When you reference a section on the same page or a different one, ensure that the anchor name matches the spelling of the anchor in the section.
- When you reference an internal file, you might have to add
../
to indicate that the file is in a different folder. Preview your changes as described previously and test the links to your file. Choose to open the link in a new tab.
IMPORTANT: Instructions for Windows is currently unavailable.
Recently, there was a shift in documentation where we needed to manage two different repositories for one Knowledge Center. As a result of this seperation, there were a ton of broken links and difficulties verifying the functionality of links. No need to worry, you are able to run the broken link tool on both repositories.
Prerequisite: You must clone the CP4MCM-docs
and common-services
repository.
Complete the following steps to run the broken link tool:
-
Select your text editor application and open your folders. For example, open the
CP4MCM-docs
folder in Visual Studio Code (VSC). -
After you open the application, open the
common-services
folder in a seperate VSC window. Select File > New Window. -
Open the terminal for both VSC windows that you have opened. From the CLI, get the updated version of the repositories. Be sure to verify your current branch. Run the following commands:
git branch git pull
-
Copy both folders and rename them. From the Finder application, double-click the folder name and select rename. For example, rename your
CP4MCM-docs
folder toCP4MCM-docs-copy
. -
Copy all of the files that are in your copied folder for
common-services
and move it into your copied folder forCP4MCM-docs
. The copied folders are now combined. -
Now, open another VSC window of the combined folder and run the broken link tool by running the following command:
find . -name "*.md" -exec markdown-link-check -q {} \; > ../combine.txt
{: codeblock}
-
Open the
combine.txt
file to view the results.
CLI task
Complete the following steps to run the broken link tool on more than one repository:
-
Copy the
.md
files of each repository and add them into a new folder. Run the following commands:cp -rf common-services-docs/ combined cp -rf CP4MCM-docs/ combined/
-
Change your directory path and run the broken link tool by running the following commands:
cd combined find . -name \*.md -exec markdown-link-check -q {} \; > broken_links.txt
{: codeblock}
{: #spell}
Install the Markdown spellcheck tool to extract misspelled words from markdown files.
Install and run the spellcheck tool from your terminal by completing the following steps:
-
Install the spellcheck tool from the CLI by running the following command:
npm i markdown-spellcheck -g
{: codeblock}
-
On your local drive, naviagte to the directory where the
docs
repository is cloned by running the following command:cd ~/Documents/docs
{: codeblock}
-
Run the spellcheck tool and create a text file with the results by running the following command:
mdspell -r -n -a --en-us *.md **/*.md **/**/*.md **/**/**/*.md > ../yourfilename.txt
{: codeblock}
-
Open the text file that has the results of the misspelled words by navigating to the file from the Finder application.
Create shortcuts on your local drive to run the spellcheck tool. Complete the following steps:
-
Right-click on your desktop. Select New > Shortcut.
-
Enter a value for the location of your tool. Your value might resemble the following path:
C:\Windows\System32\cmd.exe /k mdspell -r -n -a --en-us *.md **/*.md **/**/*.md **/**/**/*.md > ../yourfilename.txt
{: codeblock}
-
Click Next.
-
Enter a name for your command, then click Finish.
-
Right-click your new desktop shortcut and click Properties.
-
Replace any default path with the path to where the command needs to run in the Start in field. In this case, run the shortcut in the folder where you installed your
docs
repository and NPM. -
Run the command by double-clicking the shortcut. A command-line window opens and when the process is complete, it shows the path to the specified Start in location.
-
Check your specified destination for the resulting files (either your root Docs folder or your output folder).
{: #local}
Install and run the Markdown marked-it tool to access a HTML preview of your .md files. Produce a local build by completing the following steps:
-
Install marked-it-cli from the CLI by running the following command:
npm install -g marked-it-cli
{: codeblock}
Note: If your installation is unsuccessful, run the following command:
sudo npm install -g marked-it-cli
. -
Run the marked-it tool to create a local. Your command might resemble the following path:
marked-it-cli /Users/[email protected]/docs-icp/ --output=/Users/[email protected]/Documents/output --conref-file=/Users/[email protected]/Documents/docs-icp/conrefs.yml --toc-xml --overwrite --verbose
{: codeblock}
Important: According to the path that is previously provided, the results of the local build are located in my
Documents/output
folder. You can rename your output folder.
Complete the following steps to run the marked-it tool on multiple repositories from the CLI:
-
Copy the
.md
files of each repository and add them into a new folder. Run the following commands:cp -rf common-services-docs/ combined cp -rf CP4MCM-docs/ combined/
-
Change your directory path and run the marked-it tool to produce a local build for both repositories. You must use the same output folder. Run the following commands:
cd combined marked-it-cli /Users/[email protected]/CP4MCM-docs/ --output=/Users/[email protected]/Documents/output-combo --conref-file=/Users/[email protected]/Documents/docs-icp/conrefs.yml --toc-xml --overwrite --verbose marked-it-cli /Users/[email protected]/common-services-docs/ --output=/Users/[email protected]/Documents/output-combo --conref-file=/Users/[email protected]/Documents/docs-icp/conrefs.yml --toc-xml --overwrite --verbose
{: codeblock}
{: #acro}
Add Content
{: #accessible}
Add Content
{: #review}
Add Content