gravitational / teleport

The easiest, and most secure way to access and protect all of your infrastructure.
https://goteleport.com
GNU Affero General Public License v3.0
17.36k stars 1.74k forks source link

Find a way to make Prerequisites sections self-contained in our docs guides #11328

Closed ptgott closed 1 year ago

ptgott commented 2 years ago

Details

In this review of the PR that added the Machine ID Ansible guide, which was submitted after the guide was merged, klizhentas pointed out that in how-to guides, we should avoid breaking the reader's focus by requiring them to complete another guide first (see the documentation style guide).

In the Prerequisites section of this guide, along with other guides in our docs, there are links to other pages on our docs site that could break a reader's focus. Let's find a way to use partials and the (! !) syntax to avoid directing a reader away from our how-to guides.

I used the following script, based on another script I used for a similar purpose, to find docs pages with links to other docs pages in the Prerequisites section. We can also look into removing docs links from other sections, though these would be harder to spot automatically. The Prerequisites section is the only one that is unique to how-to guides, and it was straightforward to identify links in this section with a script. (Maybe we could use frontmatter to identify guides by type, e.g., how-to, getting-started, reference, etc.?)

results=$(find docs/pages -name "*.mdx" -exec awk '
# p: whether we are in a prerequisite section
# t: whether a prerequisite section exists in the doc
# c: whether we are in a code snippet
# links: number of Teleport Cloud mentions in the Prerequisites section
BEGIN{p=0; t=0; c=0; links=0} 

# We are in a code snippet
/^```/{c=1}

# We have left a code snippet
/^```/ && c==1 {c=0}

# We are in the Prerequisites section
/# Prerequisite/{p=1; t=1; next;}

# We have left the Prerequisites section
p==1 && /^#{1,} [A-Za-z0-9]+/ && c!=1{p=0;}

# There is a link to another page
p==1 && /\]\([\.\/a-z0-9A-Z-]+\.mdx/{links++}

# Print the filename only if there is a Prerequisites section
END{if (t==1){ printf "%s:%s\n", FILENAME, links;}}' {} \;)

total_count=$(echo "$results" | wc -l | tr -d "[[:space:]]");
zero_count=$(echo "$results" | grep "0$" | wc -l | tr -d "[[:space:]]");
echo -e "Summary: There are links to other docs pages in ${zero_count}/${total_count} files with Prerequisites sections\n";
echo "$results";

Here are the results:

Summary: There are links to other docs pages in 31/60 files with Prerequisites sections

docs/pages/database-access/guides/mongodb-atlas.mdx:0
docs/pages/database-access/guides/cockroachdb-self-hosted.mdx:0
docs/pages/database-access/guides/sql-server-ad.mdx:0
docs/pages/database-access/guides/postgres-redshift.mdx:0
docs/pages/database-access/guides/mongodb-self-hosted.mdx:0
docs/pages/database-access/guides/rds.mdx:0
docs/pages/database-access/guides/redis.mdx:0
docs/pages/database-access/guides/azure-postgres-mysql.mdx:0
docs/pages/machine-id/getting-started.mdx:0
docs/pages/machine-id/guides/ansible.mdx:2
docs/pages/access-controls/getting-started.mdx:1
docs/pages/access-controls/guides/per-session-mfa.mdx:2
docs/pages/access-controls/guides/impersonation.mdx:1
docs/pages/access-controls/guides/webauthn.mdx:1
docs/pages/access-controls/guides/locking.mdx:1
docs/pages/access-controls/guides/role-templates.mdx:1
docs/pages/access-controls/guides/dual-authz.mdx:1
docs/pages/access-controls/guides/u2f.mdx:1
docs/pages/enterprise/sso/google-workspace.mdx:0
docs/pages/enterprise/sso/azuread.mdx:0
docs/pages/enterprise/getting-started.mdx:0
docs/pages/enterprise/workflow/ssh-approval-mattermost.mdx:0
docs/pages/enterprise/workflow/ssh-approval-pagerduty.mdx:0
docs/pages/enterprise/workflow/ssh-approval-jira-server.mdx:1
docs/pages/enterprise/workflow/ssh-approval-slack.mdx:0
docs/pages/enterprise/hsm.mdx:0
docs/pages/desktop-access/getting-started.mdx:1
docs/pages/kubernetes-access/getting-started/agent.mdx:3
docs/pages/kubernetes-access/getting-started/cluster.mdx:1
docs/pages/kubernetes-access/guides/standalone-teleport.mdx:4
docs/pages/kubernetes-access/guides/multiple-clusters.mdx:3
docs/pages/kubernetes-access/helm/guides/gcp.mdx:0
docs/pages/kubernetes-access/helm/guides/aws.mdx:0
docs/pages/kubernetes-access/helm/guides/custom.mdx:0
docs/pages/kubernetes-access/helm/guides/migration.mdx:0
docs/pages/kubernetes-access/helm/guides/digitalocean.mdx:0
docs/pages/setup/admin/adding-nodes.mdx:1
docs/pages/setup/admin/labels.mdx:1
docs/pages/setup/admin/github-sso.mdx:1
docs/pages/setup/admin/users.mdx:1
docs/pages/setup/operations/ca-rotation.mdx:1
docs/pages/setup/operations/scaling.mdx:0
docs/pages/setup/guides/ec2-tags.mdx:0
docs/pages/setup/guides/docker.mdx:0
docs/pages/setup/guides/fluentd.mdx:0
docs/pages/setup/guides/terraform-provider.mdx:0
docs/pages/setup/guides/joining-nodes-aws.mdx:0
docs/pages/setup/deployments/aws-terraform.mdx:0
docs/pages/server-access/getting-started.mdx:1
docs/pages/server-access/guides/vscode.mdx:2
docs/pages/server-access/guides/bpf-session-recording.mdx:1
docs/pages/server-access/guides/restricted-session.mdx:0
docs/pages/getting-started/linux-server.mdx:1
docs/pages/getting-started/docker-compose.mdx:0
docs/pages/getting-started/digitalocean.mdx:0
docs/pages/api/getting-started.mdx:1
docs/pages/production.mdx:3
docs/pages/application-access/getting-started.mdx:1
docs/pages/application-access/guides/api-access.mdx:2
docs/pages/application-access/guides/aws-console.mdx:2

Category

ptgott commented 1 year ago

Going to close this, since we aren't requiring that each docs guide set up a full Teleport installation any more (https://github.com/gravitational/teleport/pull/20024). As a result, it's inevitable that a Prerequisites section will contain links to other guides.