Skip to content

Commit

Permalink
add support for pyang (#282)
Browse files Browse the repository at this point in the history
Hi, 


pyang (https://github.com/mbj4668/pyang) is a YANG validator,
transformator and code generator, written in python. YANG (RFC 7950) is
a data modeling language for NETCONF (RFC 6241), developed by the IETF
NETMOD WG. This formatter provides support for Emacs yang-mode.

---------

Co-authored-by: Radon Rosborough <[email protected]>
  • Loading branch information
sgherdao and raxod502 authored Feb 9, 2024
1 parent 96a9805 commit c07e907
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ The format is based on [Keep a Changelog].
clojurescript, edn files. ([#271])
* Stylua is used now in `lua-ts-mode` as well as just `lua-mode`, by
default ([#275]).
* [`treefmt`](https://numtide.github.io/treefmt) for project configured formatters ([#280]).
* [`treefmt`](https://numtide.github.io/treefmt) for project
configured formatters ([#280]).
* [`pyang`](https://github.com/mbj4668/pyang) for
[YANG](https://www.rfc-editor.org/rfc/rfc7950.html) ([#282]).

### Bugs fixed
* Apheleia sometimes failed to determine indent level from Emacs
Expand All @@ -53,6 +56,7 @@ The format is based on [Keep a Changelog].
[#274]: https://github.com/radian-software/apheleia/issues/274
[#275]: https://github.com/radian-software/apheleia/pull/275
[#279]: https://github.com/radian-software/apheleia/pull/279
[#282]: https://github.com/radian-software/apheleia/pull/282

## 4.0 (released 2023-11-23)
### Breaking changes
Expand Down
4 changes: 3 additions & 1 deletion apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"--parser=yaml"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(purs-tidy . ("apheleia-npx" "purs-tidy" "format"))
(pyang . ("pyang" "--ignore-errors" "-f" "yang"))
(robotidy . ("robotidy" "--no-color" "-"
(apheleia-formatters-indent nil "--indent")
(apheleia-formatters-fill-column "--line-length")))
Expand Down Expand Up @@ -370,7 +371,8 @@ rather than using this system."
(typescript-ts-mode . prettier-typescript)
(web-mode . prettier)
(yaml-mode . prettier-yaml)
(yaml-ts-mode . prettier-yaml))
(yaml-ts-mode . prettier-yaml)
(yang-mode . pyang))
"Alist mapping major mode names to formatters to use in those modes.
This determines what formatter to use in buffers without a
setting for `apheleia-formatter'. The keys are major mode
Expand Down
2 changes: 2 additions & 0 deletions test/formatters/installers/pyang.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apt-get install -y python3-pip
pip install pyang
10 changes: 10 additions & 0 deletions test/formatters/samplecode/pyang/in.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module in { namespace "http://com/in/in";
prefix
in ;

list example { key "name";
leaf name {
type string;
}
}
}
11 changes: 11 additions & 0 deletions test/formatters/samplecode/pyang/out.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module in {
namespace "http://com/in/in";
prefix in;

list example {
key "name";
leaf name {
type string;
}
}
}

0 comments on commit c07e907

Please sign in to comment.