Skip to content

Commit

Permalink
Make Code its own page
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Dec 24, 2024
1 parent 0d5046e commit 54fa964
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 53 deletions.
5 changes: 5 additions & 0 deletions src/lib/config/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ export const docsConfig: DocsConfig = {
href: "/docs/formats/dita",
items: [],
},
{
title: "Code",
href: "/docs/formats/code",
items: [],
},
],
},
{
Expand Down
59 changes: 59 additions & 0 deletions src/lib/content/formats/code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Code
description: Learn how Vale handles source code.
---

<script lang="ts">
import CodeFormats from '$lib/components/docs/CodeFormats.svelte';
</script>

Vale supports linting source code comments in a number of languages
(see below).

<CodeFormats />

## Associations

In many languages, it's common for comments to contain _embedded markup_ (e.g., Markdown, reStructuredText, etc.) within them. For example, consider the following Rust doc comment:

````rust
impl Person {
/// Creates a person with the given name.
///
/// # Examples
///
/// ```
/// // You can have rust code between fences
/// // inside the comments If you pass --test
/// // to `rustdoc`, it will even test it for
/// // you!
/// use doc::Person;
/// let person = Person::new("name");
/// ```
pub fn new(name: &str) -> Person {
Person {
name: name.to_string(),
}
}
}
````

If the embedded markup is one of the supported formats, you can
associate the `comment` scope with a `markup` type. This will allow you to
lint the embedded markup as if it were a standalone file.

```ini
StylesPath = styles
MinAlertLevel = suggestion

[formats]
# Rust + Markdown
rs = md

[*.{rs,md}]
BasedOnStyles = Vale
```

Once a markup format has been assigned, you can make use of all the
supported features of that format (such as ignore patterns and comment-based
configuration) in your source code comments.
54 changes: 1 addition & 53 deletions src/lib/content/scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ description: Learn about Vale's advanced markup-specific scoping system.
<script lang="ts">
import Alert from '$lib/components/Alert.svelte';
import Scopes from '$lib/components/docs/Scopes.svelte';
import CodeFormats from '$lib/components/docs/CodeFormats.svelte';
import { Badge } from "$lib/components/ui/badge";
</script>

Expand Down Expand Up @@ -61,58 +60,7 @@ documentation for more information and installation instructions.

There are two `code` scopes: `comment.line` and `comment.block`.

<CodeFormats />

## Associations

Vale supports linting source code comments in a number of languages
(see above).

However, it's common for comments to _embedded markup_ (e.g.,
Markdown, reStructuredText, etc.) within them. For example, consider the
following Rust doc comment:

````rust
impl Person {
/// Creates a person with the given name.
///
/// # Examples
///
/// ```
/// // You can have rust code between fences
/// // inside the comments If you pass --test
/// // to `rustdoc`, it will even test it for
/// // you!
/// use doc::Person;
/// let person = Person::new("name");
/// ```
pub fn new(name: &str) -> Person {
Person {
name: name.to_string(),
}
}
}
````

If the embedded markup is one of the supported formats, you can
associate the `comment` scope with a `markup` type. This will allow you to
lint the embedded markup as if it were a standalone file.

```ini
StylesPath = styles
MinAlertLevel = suggestion

[formats]
# Rust + Markdown
rs = md

[*.{rs,md}]
BasedOnStyles = Vale
```

Once a markup format has been assigned, you can make use of all the
supported features of that format (such as ignore patterns and comment-based
configuration) in your source code comments.
See the [Code](/docs/formats/code) documentation for more information.

## Selectors

Expand Down

0 comments on commit 54fa964

Please sign in to comment.