Skip to content

Commit

Permalink
update readme some more with improved clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
EstevanBR committed Jul 20, 2024
1 parent b357d2a commit 64e634d
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## Using lintguard
### Add `lintguard` metadata to codeblocks in Markdown files
In any Markdown (.md) file, you can augment a codeblock with extra metadata, consider a hypothetical README.md file with the following codeblock appearing somewhere:
### Add `lintguard` to codeblocks in Markdown files
In any Markdown (.md) file, you can augment a codeblock with lintguard notation.

Consider a hypothetical README.md file with the following codeblock appearing somewhere:

<pre>
```swift lintguard: ./Package.swift#L1-L19
```swift lintguard: Package.swift#L1-L19
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

Expand All @@ -27,37 +29,36 @@ let package = Package(
</pre>

The main bit of interest is the first line
<code>```swift lintguard: ./main.swift#L1-L2</code>
<code>```swift lintguard: Package.swift#L1-L19</code>
- the first three backticks <code>```</code> are the start of a standard markdown code block
- `swift` bit is also standard in markdown is the language identifier
- after the language identifier we see the token `lintguard:` this indicates to lintguard that this code block should be checked
- after the `lintguard` token, we see `./main.swift` this indicates that the codeblock is referencing the `main.swift` file
- after the filename, we see `#L1-L2`, this means that the codeblock matches lines 1-2 of the `main.swift` file

- after the `lintguard` token, we see `Package.swift` this indicates that the codeblock is referencing the `Package.swift` file
- after the filename, we see `#L1-L19`, this means that the codeblock matches lines 1-19 of the `Package.swift` file

### Using lintguard to detect out of date codeblocks in Markdown files
### Using lintguard to detect out of date codeblocks
Consider the hypothetical README.md from the previous section, once the tool is installed, simply invoke it with the paths to one or more Markdown (.md) files:
```
$ lintguard README.md
```

If any `lintguard` code blocks exist in README.md, lintguard will process them to ensure any guarded code blocks are up-to-date

We can even use it on the README.md file you are currently reading:
We can even use it on the `README.md` file you are currently reading:

This is line 31, Hello World!
This is line 49, Hello World!

This code block will pass:
````
```markdown lintguard: ./README.md#L48
This is line 31, Hello World!
```markdown lintguard: README.md#L49
This is line 49, Hello World!
```
````

And this one will fail:
````
```markdown lintguard: ./README.md#L48
This is line 31, Hello?
```markdown lintguard: README.md#L49
This is line 49, Hello?
```
````

Expand Down

0 comments on commit 64e634d

Please sign in to comment.