Skip to content

Commit

Permalink
Add yangPathIgnore setting
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
esmasth committed Apr 2, 2024
1 parent 25593e8 commit fe170ca
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 52 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ end_of_line = crlf
[*.yml]
indent_style = space
indent_size = 2

[{*.xtext,*.xtend}]
indent_size = 4
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ on:
- master

jobs:
mdlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DavidAnson/markdownlint-cli2-action@v15
with:
globs: |
**/*.md
!build/**/*.md
!bin/**/*.md
build:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
],
"url": "./schema/yang-lsp-settings-schema.json"
}
]
],
"markdownlint.ignore": ".gitignore"
}
11 changes: 7 additions & 4 deletions docs/Extensions.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Extensions

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

So far two different kinds of extensions are supported :

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

## Create a Validator

A validator extension is a Java class that implements the interface `io.typefox.yang.validation.IValidatorExtension`.
A validator extension is a Java class that implements the interface
`io.typefox.yang.validation.IValidatorExtension`.

Here is a small example:

```java
Expand Down Expand Up @@ -50,7 +53,7 @@ class MyCommand implements ICommandExtension {
* return a list of commands. A command string is used as ID internally and as a label in the UI.

Check failure on line 53 in docs/Extensions.md

View workflow job for this annotation

GitHub Actions / mdlint

Line length

docs/Extensions.md:53:81 MD013/line-length Line length [Expected: 80; Actual: 101] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md013.md
*/
override getCommands() {
#[COMMAND]
#[COMMAND]
}

/**
Expand Down
13 changes: 10 additions & 3 deletions docs/Processing_Files.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Processing YANG files

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.
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.

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:
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:

```xtend
package io.typefox.yang.example
Expand Down Expand Up @@ -66,7 +71,7 @@ class StandaloneExample {
}
```

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)
A number of useful helper methods can be found in the [utils package][1]

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

Expand Down Expand Up @@ -98,3 +103,5 @@ dependencies {
compile 'com.google.inject:guice:3.0'
}
```

[1]: https://github.com/TypeFox/yang-lsp/tree/master/yang-lsp/io.typefox.yang/src/main/java/io/typefox/yang/utils
106 changes: 75 additions & 31 deletions docs/Settings.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Settings

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

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

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

## Disable Code Lens

If you don't want to see the code lenses you can turn it of with the following property:
If you don't want to see the code lenses you can turn it of with the following
property:

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

## Excluded Paths

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.
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 informs issues about duplicate elements. To avoid that, you can exclude
several directories in the project setting `excludePath`, e.g.

```json
{
"excludePath": "build:bin"
}
```

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.
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.

## YANG Libraries

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`
Often you don't specify a self contained set of YANG models but rely on existing
standard libs instead, e.g. from the IETF. These don't necessarily reside in
your workspace. To specify such libraries, use `yangPath`

```json
{
"yangPath": "/my/home/yang/libs/rift.zip"
}
```

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).
If `yangPath` is provided to refer to an SDK location which includes a version
of the project's YANG models that need to be ignored, following approach can be
used.

```json
{
"yangPath": "/path/to/sdk/yang/dir",
"yangPathIgnore": "/path/to/sdk/yang/dir/project"
}
```

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).

## Extensions

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

## Diagnostics

The user can change the severity of diagnostics, by setting the value of a diagnostic preference key to either
The user can change the severity of diagnostics, by setting the value of a
diagnostic preference key to either

- `"error"`
- `"warning"`
- `"ignore"`

The settings contains a `diagnostics` section in which the serverioties for the below diagnostics can be adjusted.
The settings contains a `diagnostics` section in which the serverioties for the
below diagnostics can be adjusted.
An example :

```json
Expand All @@ -66,23 +90,26 @@ An example :
}
```

### Diagnostic Codes
### Diagnostic Issue Codes

#### `substatement-cardinality`

Issue code that are entangled with cardinality problems of container statement's sub-statements.
Issue code that are entangled with cardinality problems of container statement's
sub-statements.

(default severity: error)

#### `unexpected-statement`

Issue code indicating an invalid sub-statement inside its parent statement container.
Issue code indicating an invalid sub-statement inside its parent statement
container.

(default severity: error)

#### `substatement-ordering`

Issue code for cases when a sub-statement incorrectly precedes another sub-statement.
Issue code for cases when a sub-statement incorrectly precedes another
sub-statement.

(default severity: error)

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

#### `type-error`

Errors for types. Such as invalid type restriction, range error, fraction-digits issue.
Errors for types. Such as invalid type restriction, range error, fraction-digits
issue.

(default severity: error)

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

#### `missing-revision`

Diagnostic that indicates a module is available in multiple revisions when no revision is provided on an import.
Diagnostic that indicates a module is available in multiple revisions when no
revision is provided on an import.

(default severity: warning)

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

#### `revision-order`

Issue code that applies on a revision if that is not in a reverse chronological order.
Issue code that applies on a revision if that is not in a reverse chronological
order.

(default severity: warning)

#### `bad-type-name`

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

(default severity: error)

#### `bad-include-yang-version`

Issue code when there is an inconsistency between a module's version and the version of the included modules.
Issues code when there is an inconsistency between a module's version and the
version of the included modules.

(fixed severity: error)

#### `bad-import-yang-version`

Issue code when there is an inconsistency between a module's version and the version of the included modules.
Issues code when there is an inconsistency between a module's version and the
version of the included modules.

(fixed severity: error)

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

#### `enumerable-restriction-name`

Issue code indicating that an enumerable introduces a new name that is not declared among the parent restriction.
Issue code indicating that an enumerable introduces a new name that is not
declared among the parent restriction.

(default severity: error)

#### `enumerable-restriction-value`

Issue code indicating that an enumerable introduces a new value that is not declared among the parent restriction.
Issue code indicating that an enumerable introduces a new value that is not
declared among the parent restriction.

(default severity: error)

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

#### `invalid-config`

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

(default severity: error)

#### `invalid-augmentation`

Issue code when an augmented node declares invalid sub-statements. For instance when an augmented leaf node has leaf nodes.
Issue code when an augmented node declares invalid sub-statements. For instance,
when an augmented leaf node has leaf nodes.

(default severity: error)

#### `invalid-default`

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

(default severity: error)

#### `mandatory-after-default-case`

Issue code when any mandatory nodes are declared after the default case in a "choice".
Issue code when any mandatory nodes are declared after the default case in a
"choice".

(default severity: error)

#### `invalid-action-ancestor`

Issue code when an action (or notification) has a "list" ancestor node without a "key" statement.
Also applies, when an action (or notification) is declared within another action, rpc or notification.
Issue code when an action (or notification) has a "list" ancestor node without a
"key" statement. Also applies, when an action (or notification) is declared
within another action, rpc or notification.

(default severity: error)

#### `identity-cycle`

Issue code when an identity references itself, either directly or indirectly through a chain of other identities.
Issue code when an identity references itself, either directly or indirectly
through a chain of other identities.

(default severity: error)

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

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

(default severity: error)

Expand Down Expand Up @@ -280,3 +322,5 @@ Diagnostic for unresolvable Xpath expressions.

[1]: https://code.visualstudio.com/docs/languages/json#_json-with-comments
[2]: https://json-schema.org/
[3]: ../schema/yang-lsp-settings-schema.json
[4]: ./Extensions.md
11 changes: 9 additions & 2 deletions schema/yang-lsp-settings-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@
},
"excludePath": {
"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",
"type": "string"
"type": "string",
"default": ""
},
"yangPath": {
"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).",
"type": "string"
"type": "string",
"default": ""
},
"yangPathIgnore": {
"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).",
"type": "string",
"default": ""
},
"extension": {
"description": "YANG LSP extension settings",
Expand Down
Loading

0 comments on commit fe170ca

Please sign in to comment.