Skip to content

Commit

Permalink
disallow relative link references
Browse files Browse the repository at this point in the history
Summary:
force all internal links to start with '/'
{F136613}

Test Plan: yarn test

Reviewers: sashank

Reviewed By: sashank

Differential Revision: https://dagster.phacility.com/D2858
  • Loading branch information
yuhan committed May 11, 2020
1 parent 881d98e commit 5c2de1f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
18 changes: 15 additions & 3 deletions docs/next/src/__tests__/mdxInternalLinks.test.ts
Expand Up @@ -99,7 +99,7 @@ function findAllMdxFileRelativePaths(): Promise<Array<string>> {

// traverse the mdx ast to find all internal links
function collectInternalLinks(rootAstNode: any): Array<string> {
const internalLinkPrefixRegex = /^\/docs\//;
const externalLinkRegex = /^http/;

const queue = [rootAstNode];
const result = [];
Expand All @@ -112,8 +112,20 @@ function collectInternalLinks(rootAstNode: any): Array<string> {
}

if (node.type === 'link' && node.url) {
if (node.url.match(internalLinkPrefixRegex)) {
result.push(node.url.replace(internalLinkPrefixRegex, ''));
const { url } = node;
if (!url.match(externalLinkRegex)) {
if (url.startsWith('#')) {
// TODO: handle self # heading links
} else if (url.startsWith('/assets/')) {
// TODO: handle assets
} else if (url.startsWith('/docs/')) {
result.push(url.replace('/docs/', ''));
} else {
// disallow relative references
result.push(
`Do not use relative references ('${url}'). All links should start with '/'`,
);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/next/src/pages/docs/learn/demos/airline_demo.mdx
Expand Up @@ -196,7 +196,7 @@ Ideally, we want this to be a matter of flipping a config switch.
Dagster decouples the instantiation of external resources like these
from the business logic of your data pipelines. In Dagster, a set of
resources configured for a particular environment is called a
[Mode](/sections/api/apidocs/pipeline.html#modes).
[Mode](/docs/apidocs/pipeline#modes).

Let's look at how we make configurable resources available to our
pipelines with modes. In `airline_demo/pipelines.py`, you'll find that
Expand Down
8 changes: 4 additions & 4 deletions docs/next/src/pages/docs/tutorial/index.mdx
Expand Up @@ -10,11 +10,11 @@ intended to be illustrative of real data problems.

The tutorial is divided into several sections:

- [**Setup for the Tutorial**](tutorial/setup) will give you a starting point to follow the tutorial.
- [**Overview**](tutorial/overview) will teach you the fundamental concepts of Dagster: solids and pipelines.
- [**ETL with Dagster**](tutorial/basics) will teach you ways to construct and execute a simple data pipeline using
- [**Setup for the Tutorial**](/docs/tutorial/setup) will give you a starting point to follow the tutorial.
- [**Overview**](/docs/tutorial/overview) will teach you the fundamental concepts of Dagster: solids and pipelines.
- [**ETL with Dagster**](/docs/tutorial/basics) will teach you ways to construct and execute a simple data pipeline using
the basics of Dagster.
- [**Advanced Tutorials**](tutorial/advanced) will showcase Dagster's advanced features like scheduling and materializations.
- [**Advanced Tutorials**](/docs/tutorial/advanced) will showcase Dagster's advanced features like scheduling and materializations.

### What Are We Building

Expand Down
Expand Up @@ -37,4 +37,4 @@ the least caloric cereal is All-Bran with Extra Fiber (50 calories per
serving) and the most caloric cereal is Mueslix Crispy Blend (160
calories per serving).

This part of this system remains relatively immature, but yielding structured expectation results from your solid logic means that in future, tools like Dagit will be able to aggregate and track expectation results, as well as implement sophisticated policy engines to drive alerting and exception handling on a deep semantic basis. You can learn more about it by reading [Data Quality Tests Guide](learn/guides/testing/expectations).
This part of this system remains relatively immature, but yielding structured expectation results from your solid logic means that in future, tools like Dagit will be able to aggregate and track expectation results, as well as implement sophisticated policy engines to drive alerting and exception handling on a deep semantic basis. You can learn more about it by reading [Data Quality Tests Guide](/docs/learn/guides/testing/expectations).
Expand Up @@ -34,4 +34,4 @@ Obviously, in production we'll often execute pipelines in a parallel,
streaming way that doesn't admit this kind of API, which is intended to enable
local tests like this.

Dagster is written to make testing easy in a domain where it has historically been very difficult. Throughout the rest of this tutorial, we'll explore the writing of unit tests for each piece of the framework as we learn about it. You can learn more about Testing in Dagster by reading [Testing Guide](learn/guides/testing/testing).
Dagster is written to make testing easy in a domain where it has historically been very difficult. Throughout the rest of this tutorial, we'll explore the writing of unit tests for each piece of the framework as we learn about it. You can learn more about Testing in Dagster by reading [Testing Guide](/docs/learn/guides/testing/testing).

0 comments on commit 5c2de1f

Please sign in to comment.