summaryrefslogtreecommitdiff
path: root/schema
diff options
context:
space:
mode:
Diffstat (limited to 'schema')
-rw-r--r--schema/interface_definition.rnc14
-rw-r--r--schema/interface_definition.rng39
-rw-r--r--schema/op-mode-definition.rnc35
-rw-r--r--schema/op-mode-definition.rng97
4 files changed, 158 insertions, 27 deletions
diff --git a/schema/interface_definition.rnc b/schema/interface_definition.rnc
index 758d9ce1c..a338b875f 100644
--- a/schema/interface_definition.rnc
+++ b/schema/interface_definition.rnc
@@ -1,6 +1,6 @@
# interface_definition.rnc: VyConf reference tree XML grammar
#
-# Copyright (C) 2014. 2017 VyOS maintainers and contributors <maintainers@vyos.net>
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -97,6 +97,18 @@ properties = element properties
valueHelp* &
(element constraintErrorMessage { text })? &
completionHelp* &
+
+ # "docs" is used to store documentation for a node in a structured format
+ # It is used to generate documentation for the CLI and Web docs
+ (element docs {
+ (element headline { text })? &
+ (element text { text })? &
+ (element usageExample { text })? &
+ (element hints {
+ attribute type { text },
+ text
+ })*
+ })? &
# These are meaningful only for leaf nodes
(element valueless { empty })? &
diff --git a/schema/interface_definition.rng b/schema/interface_definition.rng
index 94a828c3b..d653d1b01 100644
--- a/schema/interface_definition.rng
+++ b/schema/interface_definition.rng
@@ -3,7 +3,7 @@
<!--
interface_definition.rnc: VyConf reference tree XML grammar
- Copyright (C) 2014. 2017 VyOS maintainers and contributors <maintainers@vyos.net>
+ Copyright VyOS maintainers and contributors <maintainers@vyos.io>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -142,7 +142,7 @@
Nodes may have properties
For simplicity, any property is allowed in any node,
but whether they are used or not is implementation-defined
-
+
Leaf nodes may differ in number of values that can be
associated with them.
By default, a leaf node can have only one value.
@@ -150,7 +150,7 @@
"valueless" means it can have no values at all.
"hidden" means node visibility can be toggled, eg 'dangerous' commands,
"secret" allows a node to hide its value from unprivileged users.
-
+
"priority" is used to influence node processing order for nodes
with exact same dependencies and in compatibility modes.
-->
@@ -178,6 +178,39 @@
<ref name="completionHelp"/>
</zeroOrMore>
<optional>
+ <!--
+ "docs" is used to store documentation for a node in a structured format
+ It is used to generate documentation for the CLI and Web docs
+ -->
+ <group>
+ <element name="docs">
+ <interleave>
+ <optional>
+ <element name="headline">
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name="text">
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <element name="usageExample">
+ <text/>
+ </element>
+ </optional>
+ <zeroOrMore>
+ <element name="hints">
+ <attribute name="type"/>
+ <text/>
+ </element>
+ </zeroOrMore>
+ </interleave>
+ </element>
+ </group>
+ </optional>
+ <optional>
<!-- These are meaningful only for leaf nodes -->
<group>
<element name="valueless">
diff --git a/schema/op-mode-definition.rnc b/schema/op-mode-definition.rnc
index ad41700b9..c10cf0431 100644
--- a/schema/op-mode-definition.rnc
+++ b/schema/op-mode-definition.rnc
@@ -1,6 +1,6 @@
# interface_definition.rnc: VyConf reference tree XML grammar
#
-# Copyright (C) 2014. 2017 VyOS maintainers and contributors <maintainers@vyos.net>
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -37,12 +37,35 @@ node = element node
}
# Tag nodes are containers for nodes without predefined names, like network interfaces
-# or user names (e.g. "interfaces ethernet eth0" or "user jrandomhacker")
-# Tag nodes may contain node and leafNode elements, and also nameConstraint tags
-# They must not contain other tag nodes
+# or user names (e.g. "show interfaces ethernet ethX").
+# Operational mode tag nodes can be parents to other tag nodes,
+# like in "ping <host> count <packets>".
+#
+# Some commands can be called either with or without arguments,
+# like "show interfaces ethernet eth0" (show info for eth0 only)
+# or "show interfaces ethernet" (show info about all ethernet interfaces).
+# That case is handled using the <standalone> element
tagNode = element tagNode
{
nodeNameAttr,
+ (properties? & standalone? & children? & command?)
+}
+
+# The <standalone> element is only used inside tag nodes
+# to define their behavior when they are called without arguments
+# It can provide a help string and a command.
+# Everything else is handled in the <tagNode> itself.
+standalone = element standalone
+{
+ help & command
+}
+
+# Virtual tag nodes provide a way to add a variable argument
+# to a command that also needs fixed arguments,
+# like "show ip route" that can take "show ip route bgp"
+# or a network and arguments after it, like "show ip route 10.0.0.0/8 longer-prefixes"
+virtualTagNode = element virtualTagNode
+{
(properties? & children? & command?)
}
@@ -55,9 +78,11 @@ leafNode = element leafNode
(command & properties)
}
-# Normal and tag nodes may have children
+# Normal and tag nodes may have children: nodes, leaf nodes, or tag nodes.
+# There can only be one virtual tag node child, though.
children = element children
{
+ (virtualTagNode? & (node | tagNode | leafNode)*) |
(node | tagNode | leafNode)+
}
diff --git a/schema/op-mode-definition.rng b/schema/op-mode-definition.rng
index a255aeb73..692584fb4 100644
--- a/schema/op-mode-definition.rng
+++ b/schema/op-mode-definition.rng
@@ -2,19 +2,19 @@
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<!--
interface_definition.rnc: VyConf reference tree XML grammar
-
- Copyright (C) 2014. 2017 VyOS maintainers and contributors <maintainers@vyos.net>
-
+
+ Copyright VyOS maintainers and contributors <maintainers@vyos.io>
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
@@ -59,9 +59,14 @@
</define>
<!--
Tag nodes are containers for nodes without predefined names, like network interfaces
- or user names (e.g. "interfaces ethernet eth0" or "user jrandomhacker")
- Tag nodes may contain node and leafNode elements, and also nameConstraint tags
- They must not contain other tag nodes
+ or user names (e.g. "show interfaces ethernet ethX").
+ Operational mode tag nodes can be parents to other tag nodes,
+ like in "ping <host> count <packets>".
+
+ Some commands can be called either with or without arguments,
+ like "show interfaces ethernet eth0" (show info for eth0 only)
+ or "show interfaces ethernet" (show info about all ethernet interfaces).
+ That case is handled using the <standalone> element
-->
<define name="tagNode">
<element name="tagNode">
@@ -71,6 +76,44 @@
<ref name="properties"/>
</optional>
<optional>
+ <ref name="standalone"/>
+ </optional>
+ <optional>
+ <ref name="children"/>
+ </optional>
+ <optional>
+ <ref name="command"/>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+ <!--
+ The <standalone> element is only used inside tag nodes
+ to define their behavior when they are called without arguments
+ It can provide a help string and a command.
+ Everything else is handled in the <tagNode> itself.
+ -->
+ <define name="standalone">
+ <element name="standalone">
+ <interleave>
+ <ref name="help"/>
+ <ref name="command"/>
+ </interleave>
+ </element>
+ </define>
+ <!--
+ Virtual tag nodes provide a way to add a variable argument
+ to a command that also needs fixed arguments,
+ like "show ip route" that can take "show ip route bgp"
+ or a network and arguments after it, like "show ip route 10.0.0.0/8 longer-prefixes"
+ -->
+ <define name="virtualTagNode">
+ <element name="virtualTagNode">
+ <interleave>
+ <optional>
+ <ref name="properties"/>
+ </optional>
+ <optional>
<ref name="children"/>
</optional>
<optional>
@@ -92,16 +135,33 @@
</interleave>
</element>
</define>
- <!-- Normal and tag nodes may have children -->
+ <!--
+ Normal and tag nodes may have children: nodes, leaf nodes, or tag nodes.
+ There can only be one virtual tag node child, though.
+ -->
<define name="children">
<element name="children">
- <oneOrMore>
- <choice>
- <ref name="node"/>
- <ref name="tagNode"/>
- <ref name="leafNode"/>
- </choice>
- </oneOrMore>
+ <choice>
+ <interleave>
+ <optional>
+ <ref name="virtualTagNode"/>
+ </optional>
+ <zeroOrMore>
+ <choice>
+ <ref name="node"/>
+ <ref name="tagNode"/>
+ <ref name="leafNode"/>
+ </choice>
+ </zeroOrMore>
+ </interleave>
+ <oneOrMore>
+ <choice>
+ <ref name="node"/>
+ <ref name="tagNode"/>
+ <ref name="leafNode"/>
+ </choice>
+ </oneOrMore>
+ </choice>
</element>
</define>
<!--
@@ -139,10 +199,11 @@
<!--
completionHelp tags contain information about allowed values of a node that is used for generating
tab completion in the CLI frontend and drop-down lists in GUI frontends
- It is only meaninful for leaf nodes
+ It is only meaningful for leaf nodes
Allowed values can be given as a fixed list of values (e.g. <list>foo bar baz</list>),
as a configuration path (e.g. <path>interfaces ethernet</path>),
- or as a path to a script file that generates the list (e.g. <script>/usr/lib/foo/list-things</script>
+ as a path to a script file that generates the list (e.g. <script>/usr/lib/foo/list-things</script>,
+ or to enable built-in image path completion (<imagePath/>).
-->
<define name="completionHelp">
<element name="completionHelp">