Skip to content

Commit 45e072b

Browse files
authored
Md link plugin listed (#830)
* add plugin to list * Add LICENSE and refactor readMarkdownWithLinks documentation Extract reference documentation to separate file and include it via snippet in README.
1 parent c65081b commit 45e072b

File tree

4 files changed

+50
-46
lines changed

4 files changed

+50
-46
lines changed

docs/filter-function-plugins.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ JavaScript plugins that enable custom filter functions for gitStream. To learn h
3636

3737
--8<-- "plugins/filters/isFlaggedUser/README.md"
3838

39+
--8<-- "plugins/filters/readMarkdownWithLinks/README.md"
40+
3941
---
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 LinearB
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
--8<-- "plugins/filters/readMarkdownWithLinks/reference.md"
2+
13
??? note "Plugin Code: readMarkdownWithLinks"
24
```javascript
35
--8<-- "plugins/filters/readMarkdownWithLinks/index.js"
@@ -7,51 +9,6 @@
79
</span>
810
</div>
911

10-
The main use case for this plugin is enhancing LinearB AI code reviews with comprehensive documentation context.
11-
12-
### Basic Usage
13-
```yaml
14-
guidelines: |
15-
{{ "REVIEW_RULES.md" | readMarkdownWithLinks | dump }}
16-
17-
Additional Context:
18-
{{ "README.md" | readMarkdownWithLinks(maxDepth=2) | dump }}
19-
```
20-
21-
## Configuration Options
22-
23-
- `followLinks` (boolean, default: `true`): Whether to follow internal markdown links
24-
- `maxDepth` (number, default: `3`): Maximum depth to follow links to prevent excessive recursion
25-
26-
## API
27-
28-
### `readMarkdownWithLinks(filePath, options)`
29-
30-
Returns the combined content of the main file and all linked files as a formatted string.
31-
32-
### `readMarkdown(filePath, options)`
33-
34-
Returns a structured object containing:
35-
- `path`: Absolute path to the file
36-
- `content`: File content
37-
- `error`: Any error encountered
38-
- `linkedFiles`: Array of linked file objects with the same structure
39-
40-
## Example Output
41-
```
42-
=== main.md ===
43-
# Main Document
44-
Content of main document...
45-
46-
=== related.md ===
47-
# Related Document
48-
Content of related document...
49-
50-
=== subdoc.md ===
51-
# Sub Document
52-
Content of sub document...
53-
```
54-
5512

5613
??? example "gitStream CM Example: readMarkdownWithLinks"
5714
```yaml+jinja
@@ -62,4 +19,4 @@ Content of main document...
6219
</span>
6320
</div>
6421

65-
[Download Source Code](https://github.com/linear-b/gitstream/tree/main/plugins/filters/readMarkdownWithLinks)
22+
[Download Source Code](https://github.com/linear-b/gitstream/tree/main/plugins/filters/readMarkdownWithLinks)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<a name="module_readMarkdownWithLinks"></a>
2+
3+
## readMarkdownWithLinks
4+
Reads a markdown file and follows internal links to create a comprehensive document view. Prevents circular references and supports configurable depth limits.
5+
6+
**Returns**: <code>string</code> - Combined content of the file and all linked files with headers, or structured object if structured option is true
7+
**License**: MIT
8+
9+
| Param | Type | Default | Description |
10+
| --- | --- | --- | --- |
11+
| filePath | <code>string</code> | | Path to the markdown file to read |
12+
| [options] | <code>Object</code> | <code>{}</code> | Configuration options for link following |
13+
| [options.followLinks] | <code>boolean</code> | <code>true</code> | Whether to follow internal markdown links |
14+
| [options.maxDepth] | <code>number</code> | <code>3</code> | Maximum depth to follow links to prevent excessive recursion |
15+
| [options.structured] | <code>boolean</code> | <code>false</code> | Return structured data instead of combined text |
16+
17+
**Example**
18+
```js
19+
{{ "docs/README.md" | readMarkdownWithLinks }}
20+
```
21+
**Example**
22+
```js
23+
{{ "docs/README.md" | readMarkdownWithLinks(maxDepth=2) }}
24+
```

0 commit comments

Comments
 (0)