Skip to content

Commit

Permalink
[docs] Fix the code block transformer so it doesn't include
Browse files Browse the repository at this point in the history
line comments/pragmas
  • Loading branch information
PedramNavid committed Feb 25, 2024
1 parent a49e052 commit bea4af6
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 18 deletions.
Binary file modified docs/content/api/modules.json.gz
Binary file not shown.
Binary file modified docs/content/api/searchindex.json.gz
Binary file not shown.
Binary file modified docs/content/api/sections.json.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/content/concepts/configuration/advanced-config-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class ProcessUsersConfig(Config):
def process_users(config: ProcessUsersConfig):
for user, permission in config.users_list.items():
if permission == UserPermissions.ADMIN:
print(f"{user} is an admin") # noqa: T201
print(f"{user} is an admin")

@job
def process_users_job():
Expand Down Expand Up @@ -372,7 +372,7 @@ executed = {}

@op
def greet_user(config: UserConfig) -> None:
print(f"Hello {config.name}!") # noqa: T201
print(f"Hello {config.name}!")
executed["greet_user"] = True

@job
Expand Down
2 changes: 1 addition & 1 deletion docs/content/concepts/configuration/config-schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MyOpConfig(Config):

@op
def print_greeting(config: MyOpConfig):
print(f"hello {config.person_name}") # noqa: T201
print(f"hello {config.person_name}")
```

You can also build config into [jobs](/concepts/ops-jobs-graphs/jobs).
Expand Down
2 changes: 1 addition & 1 deletion docs/content/concepts/ops-jobs-graphs/nesting-graphs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ from dagster import GraphOut
@op
def echo(i):
print(i) # noqa: T201
print(i)
@op
Expand Down
4 changes: 2 additions & 2 deletions docs/content/guides/dagster-pipes/databricks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def databricks_asset(
}
)

print("This will be forwarded back to Dagster stdout") # noqa: T201
print("This will be forwarded back to Dagster stderr", file=sys.stderr) # noqa: T201
print("This will be forwarded back to Dagster stdout")
print("This will be forwarded back to Dagster stderr", file=sys.stderr)

extras = {"some_parameter": 100}

Expand Down
12 changes: 6 additions & 6 deletions docs/next/components/mdx/MDXComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

// For example, if you need to update `PyObject`, rename the existing component to `PyObjectLegacy`
// and update all existing usage of it
import {LATEST_VERSION} from 'util/version';
import { LATEST_VERSION } from 'util/version';

import {Tab, Transition} from '@headlessui/react';
import { Tab, Transition } from '@headlessui/react';
import cx from 'classnames';
import {PersistentTabContext} from 'components/PersistentTabContext';
import { PersistentTabContext } from 'components/PersistentTabContext';
import NextImage from 'next/image';
import NextLink from 'next/link';
import React, {ReactElement, useCallback, useContext, useEffect, useRef, useState} from 'react';
import React, { ReactElement, useCallback, useContext, useEffect, useRef, useState } from 'react';
import Zoom from 'react-medium-image-zoom';

import Icons from '../Icons';
import Link from '../Link';
import {Note, Warning} from '../markdoc/Callouts';
import { Note, Warning } from '../markdoc/Callouts';

import 'react-medium-image-zoom/dist/styles.css';
import {RenderedDAG} from './RenderedDAG';
import { RenderedDAG } from './RenderedDAG';
import EnvVarsBenefits from './includes/EnvVarsBenefits.mdx';
import EnvironmentVariablesIntro from './includes/EnvironmentVariablesIntro.mdx';
import AddGitlabVariable from './includes/dagster-cloud/AddGitlabVariable.mdx';
Expand Down
Binary file modified docs/next/public/objects.inv
Binary file not shown.
17 changes: 11 additions & 6 deletions docs/next/util/codeBlockTransformer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {promises as fs} from 'fs';
import { promises as fs } from 'fs';
import path from 'path';

import {Node} from 'hast';
import { Node } from 'hast';
import visit from 'unist-util-visit';

import {limitSnippetLines} from './limit';
import { limitSnippetLines } from './limit';

const DAGSTER_REPO = process.env.DAGSTER_REPO || path.join(__dirname, '../../../');

Expand Down Expand Up @@ -81,9 +81,14 @@ export default ({setCodeBlockStats: setCodeBlockStats}: CodeTransformerOptions)
);

// remove pragmas
contentWithLimit = contentWithLimit.replace(/^\s*# (type|ruff|isort|noqa):.*$/g, '');
contentWithLimit = contentWithLimit.replace(/ # (type|ruff|isort|noqa):.*$/g, '');

contentWithLimit = contentWithLimit.replace(
/^\s*# (type|ruff|isort|noqa|pyright):.*$/g,
'',
);
contentWithLimit = contentWithLimit.replace(
/(.*?)(# (type|ruff|isort|noqa|pyright):.*)$/gm,
'$1',
);
if (metaOptions.trim) {
contentWithLimit = contentWithLimit.trim();
}
Expand Down

0 comments on commit bea4af6

Please sign in to comment.