Skip to content

Commit fe170ca

Browse files
committed
Add yangPathIgnore setting
This allows for exclusion of specific subdirs or files under the dirs specified via `yangPath`. Also added github ci checks markdown files to fix markdownlint issues. This addresses #232 Signed-off-by: Siddharth Sharma <[email protected]>
1 parent 25593e8 commit fe170ca

File tree

8 files changed

+144
-52
lines changed

8 files changed

+144
-52
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ end_of_line = crlf
2828
[*.yml]
2929
indent_style = space
3030
indent_size = 2
31+
32+
[{*.xtext,*.xtend}]
33+
indent_size = 4

.github/workflows/main.yml

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ on:
99
- master
1010

1111
jobs:
12+
mdlint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: DavidAnson/markdownlint-cli2-action@v15
17+
with:
18+
globs: |
19+
**/*.md
20+
!build/**/*.md
21+
!bin/**/*.md
1222
build:
1323
runs-on: ubuntu-latest
1424
steps:

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
],
1010
"url": "./schema/yang-lsp-settings-schema.json"
1111
}
12-
]
12+
],
13+
"markdownlint.ignore": ".gitignore"
1314
}

docs/Extensions.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Extensions
22

3-
The yang-lsp allows to have additional third party extensions, configured through `yang.settings`.
4-
For details on file format and schema see [Settings.md](./Settings.md).
3+
The yang-lsp allows to have additional third party extensions, configured
4+
through `yang.settings`. For details on file format and schema see
5+
[Settings.md](./Settings.md).
56

67
So far two different kinds of extensions are supported :
78

@@ -10,7 +11,9 @@ So far two different kinds of extensions are supported :
1011

1112
## Create a Validator
1213

13-
A validator extension is a Java class that implements the interface `io.typefox.yang.validation.IValidatorExtension`.
14+
A validator extension is a Java class that implements the interface
15+
`io.typefox.yang.validation.IValidatorExtension`.
16+
1417
Here is a small example:
1518

1619
```java
@@ -50,7 +53,7 @@ class MyCommand implements ICommandExtension {
5053
* return a list of commands. A command string is used as ID internally and as a label in the UI.
5154
*/
5255
override getCommands() {
53-
#[COMMAND]
56+
#[COMMAND]
5457
}
5558

5659
/**

docs/Processing_Files.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# Processing YANG files
22

3-
As yang-lsp contains all the tools to parse, link and validate YANG models. If you want to further process the YANG files you authored with yang-lsp it makes sense to make reuse of the existing functionality.
3+
As yang-lsp contains all the tools to parse, link and validate YANG models. If
4+
you want to further process the YANG files you authored with yang-lsp it makes
5+
sense to make reuse of the existing functionality.
46

5-
Here is some example code in Xtend for an application that reads in all YANG files from a given directory. The files are parsed into our YANG EMF model, all cross-references are resolved and all files are validated. If there are no errors, the method `generate()` is called for all resources:
7+
Here is some example code in Xtend for an application that reads in all YANG
8+
files from a given directory. The files are parsed into our YANG EMF model, all
9+
cross-references are resolved and all files are validated. If there are no
10+
errors, the method `generate()` is called for all resources:
611

712
```xtend
813
package io.typefox.yang.example
@@ -66,7 +71,7 @@ class StandaloneExample {
6671
}
6772
```
6873

69-
A number of useful helper methods can be found in the [utils package](https://github.com/TypeFox/yang-lsp/tree/master/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/utils)
74+
A number of useful helper methods can be found in the [utils package][1]
7075

7176
Here is sample `build.gradle` to build the above class:
7277

@@ -98,3 +103,5 @@ dependencies {
98103
compile 'com.google.inject:guice:3.0'
99104
}
100105
```
106+
107+
[1]: https://github.com/TypeFox/yang-lsp/tree/master/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/utils

docs/Settings.md

+75-31
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Settings
22

3-
The yang-lsp allows users to configure various settings, through settings files.
3+
The yang-lsp allows users to configure various settings, through setting files.
44
The settings file has the name `yang.settings` and can be located
55

66
- at the root of a project
77
- in the user's directory under `~/.yang/yang.settings`.
88

99
The file syntax is a [JSON with Comments][1], and its [JSON Schema][2] can be
10-
found [here](../schema/yang-lsp-settings-schema.json).
10+
found [here][3].
1111

1212
## Disable Code Lens
1313

14-
If you don't want to see the code lenses you can turn it of with the following property:
14+
If you don't want to see the code lenses you can turn it of with the following
15+
property:
1516

1617
```json
1718
{
@@ -21,41 +22,64 @@ If you don't want to see the code lenses you can turn it of with the following p
2122

2223
## Excluded Paths
2324

24-
Many IDEs and tools copy YANG files into another folder within the same project. As the YANG LSP treats all files within a project the same, this usually infers issues about duplicate elements. To avoid that, you can exclude several directories in the project setting `excludePath`, e.g.
25+
Many IDEs and tools copy YANG files into another folder within the same
26+
project. As the YANG LSP treats all files within a project the same, this
27+
usually informs issues about duplicate elements. To avoid that, you can exclude
28+
several directories in the project setting `excludePath`, e.g.
2529

2630
```json
2731
{
2832
"excludePath": "build:bin"
2933
}
3034
```
3135

32-
exludes the default output folder of Maven/Gradle and Eclipse JDT. The path elements are project relative directory names. You can specify multiple elements separated with a colon. The file separator is always `/` independent from the OS.
36+
exludes the default output folder of Maven/Gradle and Eclipse JDT. The path
37+
elements are project relative directory names. You can specify multiple elements
38+
separated with a colon. The file separator is always `/` independent from the
39+
OS.
3340

3441
## YANG Libraries
3542

36-
Often you don't specify a self contained set of YANG models but rely on existing standard libs instead, e.g. from the IETF. Thes don't necessarily reside in your workspace. To specify such libraries, use `yangPath`
43+
Often you don't specify a self contained set of YANG models but rely on existing
44+
standard libs instead, e.g. from the IETF. These don't necessarily reside in
45+
your workspace. To specify such libraries, use `yangPath`
3746

3847
```json
3948
{
4049
"yangPath": "/my/home/yang/libs/rift.zip"
4150
}
4251
```
4352

44-
You can specify individual files, directories (contents will be added recursively) or ZIP files. The file name format is OS specific, and so is the path separator (`;` on Windows, `:` elsewhere).
53+
If `yangPath` is provided to refer to an SDK location which includes a version
54+
of the project's YANG models that need to be ignored, following approach can be
55+
used.
56+
57+
```json
58+
{
59+
"yangPath": "/path/to/sdk/yang/dir",
60+
"yangPathIgnore": "/path/to/sdk/yang/dir/project"
61+
}
62+
```
63+
64+
You can specify individual files, directories (contents will be added
65+
recursively) or ZIP files. The file name format is OS specific, and so is the
66+
path separator (`;` on Windows, `:` elsewhere).
4567

4668
## Extensions
4769

48-
The settings is used to register an extension. Please find the details [here](Extensions.md).
70+
The settings is used to register an extension. Please find the details [here][4].
4971

5072
## Diagnostics
5173

52-
The user can change the severity of diagnostics, by setting the value of a diagnostic preference key to either
74+
The user can change the severity of diagnostics, by setting the value of a
75+
diagnostic preference key to either
5376

5477
- `"error"`
5578
- `"warning"`
5679
- `"ignore"`
5780

58-
The settings contains a `diagnostics` section in which the serverioties for the below diagnostics can be adjusted.
81+
The settings contains a `diagnostics` section in which the serverioties for the
82+
below diagnostics can be adjusted.
5983
An example :
6084

6185
```json
@@ -66,23 +90,26 @@ An example :
6690
}
6791
```
6892

69-
### Diagnostic Codes
93+
### Diagnostic Issue Codes
7094

7195
#### `substatement-cardinality`
7296

73-
Issue code that are entangled with cardinality problems of container statement's sub-statements.
97+
Issue code that are entangled with cardinality problems of container statement's
98+
sub-statements.
7499

75100
(default severity: error)
76101

77102
#### `unexpected-statement`
78103

79-
Issue code indicating an invalid sub-statement inside its parent statement container.
104+
Issue code indicating an invalid sub-statement inside its parent statement
105+
container.
80106

81107
(default severity: error)
82108

83109
#### `substatement-ordering`
84110

85-
Issue code for cases when a sub-statement incorrectly precedes another sub-statement.
111+
Issue code for cases when a sub-statement incorrectly precedes another
112+
sub-statement.
86113

87114
(default severity: error)
88115

@@ -94,7 +121,8 @@ Issue code that is used when a module has anything but {@code '1.1'} version.
94121

95122
#### `type-error`
96123

97-
Errors for types. Such as invalid type restriction, range error, fraction-digits issue.
124+
Errors for types. Such as invalid type restriction, range error, fraction-digits
125+
issue.
98126

99127
(default severity: error)
100128

@@ -110,7 +138,8 @@ A duplicate local name.
110138

111139
#### `missing-revision`
112140

113-
Diagnostic that indicates a module is available in multiple revisions when no revision is provided on an import.
141+
Diagnostic that indicates a module is available in multiple revisions when no
142+
revision is provided on an import.
114143

115144
(default severity: warning)
116145

@@ -140,26 +169,30 @@ Issue code when the revision date does not conform the "YYYY-MM-DD" format.
140169

141170
#### `revision-order`
142171

143-
Issue code that applies on a revision if that is not in a reverse chronological order.
172+
Issue code that applies on a revision if that is not in a reverse chronological
173+
order.
144174

145175
(default severity: warning)
146176

147177
#### `bad-type-name`
148178

149-
Issue code when the name of a type does not conform with the existing constraints.
150-
For instance; the name contains any invalid characters, or equals to any YANG built-in type name.
179+
Issue code when the name of a type does not conform with the existing
180+
constraints. For instance, the name contains any invalid characters, or equals
181+
to any YANG built-in type name.
151182

152183
(default severity: error)
153184

154185
#### `bad-include-yang-version`
155186

156-
Issue code when there is an inconsistency between a module's version and the version of the included modules.
187+
Issues code when there is an inconsistency between a module's version and the
188+
version of the included modules.
157189

158190
(fixed severity: error)
159191

160192
#### `bad-import-yang-version`
161193

162-
Issue code when there is an inconsistency between a module's version and the version of the included modules.
194+
Issues code when there is an inconsistency between a module's version and the
195+
version of the included modules.
163196

164197
(fixed severity: error)
165198

@@ -177,13 +210,15 @@ Issue code indicating that all assigned values in an enumerable must be unique.
177210

178211
#### `enumerable-restriction-name`
179212

180-
Issue code indicating that an enumerable introduces a new name that is not declared among the parent restriction.
213+
Issue code indicating that an enumerable introduces a new name that is not
214+
declared among the parent restriction.
181215

182216
(default severity: error)
183217

184218
#### `enumerable-restriction-value`
185219

186-
Issue code indicating that an enumerable introduces a new value that is not declared among the parent restriction.
220+
Issue code indicating that an enumerable introduces a new value that is not
221+
declared among the parent restriction.
187222

188223
(default severity: error)
189224

@@ -207,44 +242,51 @@ Controls the indentation string when formatting or serializing yang files.
207242

208243
#### `invalid-config`
209244

210-
Issue code when a `config=true` is a child of a `config=false` (see <https://tools.ietf.org/html/rfc7950#section-7.21.1>)
245+
Issue code when a `config=true` is a child of a `config=false`
246+
(see <https://tools.ietf.org/html/rfc7950#section-7.21.1>)
211247

212248
(default severity: error)
213249

214250
#### `invalid-augmentation`
215251

216-
Issue code when an augmented node declares invalid sub-statements. For instance when an augmented leaf node has leaf nodes.
252+
Issue code when an augmented node declares invalid sub-statements. For instance,
253+
when an augmented leaf node has leaf nodes.
217254

218255
(default severity: error)
219256

220257
#### `invalid-default`
221258

222-
Issue code for cases when the a choice has default value and the mandatory sub-statement is "true".
259+
Issue code for cases when the a choice has default value and the mandatory
260+
sub-statement is "true".
223261

224262
(default severity: error)
225263

226264
#### `mandatory-after-default-case`
227265

228-
Issue code when any mandatory nodes are declared after the default case in a "choice".
266+
Issue code when any mandatory nodes are declared after the default case in a
267+
"choice".
229268

230269
(default severity: error)
231270

232271
#### `invalid-action-ancestor`
233272

234-
Issue code when an action (or notification) has a "list" ancestor node without a "key" statement.
235-
Also applies, when an action (or notification) is declared within another action, rpc or notification.
273+
Issue code when an action (or notification) has a "list" ancestor node without a
274+
"key" statement. Also applies, when an action (or notification) is declared
275+
within another action, rpc or notification.
236276

237277
(default severity: error)
238278

239279
#### `identity-cycle`
240280

241-
Issue code when an identity references itself, either directly or indirectly through a chain of other identities.
281+
Issue code when an identity references itself, either directly or indirectly
282+
through a chain of other identities.
242283

243284
(default severity: error)
244285

245286
#### `leaf-key-with-if-feature`
246287

247-
This issue code is used when a leaf node is declared as a list key and have any "if-feature" statements.
288+
This issue code is used when a leaf node is declared as a list key and have any
289+
"if-feature" statements.
248290

249291
(default severity: error)
250292

@@ -280,3 +322,5 @@ Diagnostic for unresolvable Xpath expressions.
280322

281323
[1]: https://code.visualstudio.com/docs/languages/json#_json-with-comments
282324
[2]: https://json-schema.org/
325+
[3]: ../schema/yang-lsp-settings-schema.json
326+
[4]: ./Extensions.md

schema/yang-lsp-settings-schema.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@
1616
},
1717
"excludePath": {
1818
"description": "The path elements are project relative directory names.\nYou can specify multiple elements separated with a colon ':'.\nThe file separator is always '/' independent from the OS",
19-
"type": "string"
19+
"type": "string",
20+
"default": ""
2021
},
2122
"yangPath": {
2223
"description": "You can specify individual files, directories (contents will be added recursively) or ZIP files.\nThe file name format is OS specific, and so is the path separator (';' on Windows, ':' elsewhere).",
23-
"type": "string"
24+
"type": "string",
25+
"default": ""
26+
},
27+
"yangPathIgnore": {
28+
"description": "You can specify individual files or directories to be ignored from `yangPath`.\nThe file name format is OS specific, and so is the path separator (';' on Windows, ':' elsewhere).",
29+
"type": "string",
30+
"default": ""
2431
},
2532
"extension": {
2633
"description": "YANG LSP extension settings",

0 commit comments

Comments
 (0)