<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'>
<?rfc toc="yes"?>
<?rfc compact="no"?>
<?rfc subcompact="no"?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc iprnotified="no"?>
<?rfc strict="yes"?>
<rfc ipr="trust200902"   category="std"
    docName="draft-ietf-netmod-yang-tree-diagrams-01" >
    <front>
    <title abbrev="YANG Tree Diagrams">YANG Tree Diagrams</title>

    <author initials="M" surname="Bjorklund" fullname='Martin Bjorklund' >
      <organization>Tail-f Systems</organization>
      <address>
        <email>mbj@tail-f.com</email>
      </address>
    </author>
    <author initials="L" surname="Berger" fullname='Lou Berger' role="editor">
      <organization>LabN Consulting, L.L.C.</organization>
      <address>
        <email>lberger@labn.net</email>
      </address>
    </author>
	<date/>
    <abstract>
	<t>
This document captures the current syntax used in YANG module Tree
Diagrams.  The purpose of the document is to provide a single location
for this definition.  This syntax may be updated from time to time
based on the evolution of the YANG language.
	</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="introduction">
    <t>
YANG Tree Diagrams were first published in <xref target="RFC7223"/>.  Such diagrams
are commonly used to provided a simplified graphical representation of
a data model and can be automatically generated via tools such as
&quot;pyang&quot;.  (See &lt;https://github.com/mbj4668/pyang&gt;).  This document
provides the syntax used in YANG Tree Diagrams.  It is expected that
this document will be updated or replaced as changes to the YANG
language, see <xref target="RFC7950"/>, necessitate.
    </t>
    <t>
Today&apos;s common practice is include the definition of the syntax used
to represent a YANG module in every document that provides a tree
diagram.  This practice has several disadvantages and the purpose of
the document is to provide a single location for this definition.  It
is not the intent of this document to restrict future changes, but
rather to ensure such changes are easily identified and suitably
agreed upon.
    </t>
    <t>
An example tree diagram can be found in <xref target="RFC7223"/> Section 3.  A
portion of which follows:
    </t>
	<figure>
	    <artwork><![CDATA[
  +--rw interfaces
  |  +--rw interface* [name]
  |     +--rw name                        string
  |     +--rw description?                string
  |     +--rw type                        identityref
  |     +--rw enabled?                    boolean
  |     +--rw link-up-down-trap-enable?   enumeration
	    ]]></artwork>
	</figure>
    <t>
The remainder of this document contains YANG Tree Diagram syntax
based on output from pyang version 1.7.1.
    </t>
</section>
<section title="Tree Diagram Syntax" anchor="tree-diagram-syntax">
    <t>
This section provides the meaning of the symbols used in YANG Tree
diagrams.
    </t>
    <t>
A full tree diagram of a module represents all elements.  It includes
the name of the module and sections for top level module statements
(typically containers), augmentations, rpcs and notifications all
identified under a module statement.  Module trees may be included in a
document as a whole, by one or more sections, or even subsets of nodes.
    </t>
    <t>
A module is identified by &quot;module:&quot; followed the module-name. Top
level module statements are listed immediately following, offset by 4
spaces.  Augmentations are listed next, offset by 2 spaces and
identified by the keyword &quot;augment&quot; followed by the augment target node
and a colon (&apos;:&apos;) character.  This is followed by, RPCs which are
identified by &quot;rpcs:&quot; and are also offset by 2 spaces.  Notifications
are last and are identified by &quot;notifications:&quot; and are also offset by 2
spaces.
    </t>
    <t>
The relative organization of each section is provided using a text-based
format that is typical of a file system directory tree display command.
Each node in the tree is prefaces with &apos;+&#8209;&#8209;&apos;.  Schema nodes that are
children of another node are offset from the parent by 3 spaces.  Schema
peer nodes separated are listed with the same space offset and, when
separated by lines, linked via a pipe (&apos;|&apos;) character.
    </t>
    <t>
The full format, including spacing conventions is:
    </t>
    <t>
module: &lt;module&#8209;name&gt;
    </t>
	<figure>
	    <artwork><![CDATA[
  +--<node>
  |  +--<node>
  |     +--<node>
  +--<node>
     +--<node>
        +--<node>
  augment <target-node>:
    +--<node>
       +--<node>
       +--<node>
          +--<node>
	    ]]></artwork>
	</figure>
	<figure>
	    <artwork><![CDATA[
  rpcs:
    +--<node>
    +--<node>

  notifications:
    +--<node>
       +--<node>
       |  +--<node>
       +--<node>
	    ]]></artwork>
	</figure>
<section title="Submodules" anchor="submodules">
    <t>
Submodules are represented in the same fashion as modules, but are
identified by &quot;submodule:&quot; followed the (sub)module-name.  For example:
    </t>
    <t>
submodule: &lt;module&#8209;name&gt;
    </t>
	<figure>
	    <artwork><![CDATA[
  +--<node>
  |  +--<node>
  |     +--<node>
	    ]]></artwork>
	</figure>
</section>
<section title="Groupings" anchor="groupings">
    <t>
Nodes within a used grouping are expanded as if the nodes were defined
at the location of the uses statement.
    </t>
</section>
<section title="Collapsed Node Representation" anchor="collapsed-node-representation">
    <t>
At times when the composition of the nodes within a module schema are
not important in the context of the presented tree, peer nodes and their
children can be collapsed using the notation &apos;...&apos; in place of the
text lines used to represent the summarized nodes.  For example:
    </t>
	<figure>
	    <artwork><![CDATA[
  +--<node>
  |  ...
  +--<node>
     +--<node>
        +--<node>
	    ]]></artwork>
	</figure>
</section>
<section title="Node Representation" anchor="node-representation">
    <t>
Each node in a YANG module is printed as:
    </t>
    <t>
&lt;status&gt; &lt;flags&gt; &lt;name&gt; &lt;opts&gt; &lt;type&gt; &lt;if&#8209;features&gt;
    </t>
	<figure>
	    <artwork><![CDATA[
  <status> is one of:
    +  for current
    x  for deprecated
    o  for obsolete

  <flags> is one of:
    rw  for configuration data
    ro  for non-configuration data
    -x  for rpcs and actions
    -n  for notifications
    mp   for schema mount points

  <name> is the name of the node
    (<name>) means that the node is a choice node
   :(<name>) means that the node is a case node

   If the node is augmented into the tree from another module, its
	    ]]></artwork>
	</figure>
	<figure>
	    <artwork><![CDATA[
   name is printed as <prefix>:<name>.

  <opts> is one of:
    ?  for an optional leaf, choice, anydata or anyxml
    !  for a presence container
    *  for a leaf-list or list
    [<keys>] for a list's keys
    /  for a mounted module
    @  for a node made available via a schema mount
       parent reference

  <type> is the name of the type for leafs and leaf-lists

    If the type is a leafref, the type is printed as "-> TARGET",
    where TARGET is either the leafref path, with prefixed removed
    if possible.

  <if-features> is the list of features this node depends on,
  printed within curly brackets and a question mark "{...}?"
	    ]]></artwork>
	</figure>
</section>
<section title="Extensions" anchor="extensions">
    <t>
TBD
    </t>
</section>
</section>
<section title="Usage Guidelines For RFCs" anchor="usage-guidelines-for-rfcs">
    <t>
This section provides general guidelines related to the use of tree
diagrams in RFCs.  This section covers [Authors&apos; note: will cover]
different types of trees and when to use them; for example, complete
module trees, subtrees, trees for groupings etc.
    </t>
<section title="Wrapping Long Lines" anchor="wrapping-long-lines">
    <t>
Internet Drafts and RFCs limit the number of characters that may in a
line of text to 72 characters.  When the tree representation of a node
results in line being longer than this limit the line should be broken
between &lt;opts&gt; and &lt;type&gt;.  The type should be indented so that the new
line starts below &lt;name&gt; with a white space offset of at least two
characters. For example:
    </t>
	<figure>
	    <artwork><![CDATA[
  notifications:
    +---n yang-library-change
       +--ro module-set-id
               -> /modules-state/module-set-id
	    ]]></artwork>
	</figure>
    <t>
The previously &apos;pyang&apos; command can be helpful in producing such output,
for example the above example was produced using:
    </t>
	<figure>
	    <artwork><![CDATA[
  pyang -f tree --tree-line-length 50 < ietf-yang-library.yang
	    ]]></artwork>
	</figure>
</section>
</section>
<section title="YANG Schema Mount Tree Diagrams" anchor="yang-schema-mount-tree-diagrams">
    <t>
YANG Schema Mount is defined in <xref target="I-D.ietf-netmod-schema-mount"/> and
warrants some specific discussion. Schema mount document is a generic
mechanism that allows for mounting one data model consisting of any
number of YANG modules at a specified location of another (parent)
schema.  Modules containing mount points will identify mount points by
name using the mount-point extension. These mount-points should be
identified, as indicated above using the &apos;mp&apos; flag.  For example:
    </t>
	<figure>
	    <artwork><![CDATA[
    module: ietf-network-instance
      +--rw network-instances
         +--rw network-instance* [name]
            +--rw name           string
            +--rw enabled?       boolean
            +--rw description?   string
            +--rw (ni-type)?
            +--rw (root-type)?
               +--:(vrf-root)
               |  +--mp vrf-root?
	    ]]></artwork>
	</figure>
    <t>
Note that a mount point definition alone is not sufficient to identify
if a mount point configuration or for non-configuration data.  This is
determined by the yang-schema-mount module &apos;config&apos; leaf associated with
the specific mount point.
    </t>
    <t>
In describing the intended use of a module containing a mount point, it
is helpful to show how the mount point would look with mounted modules.
In such cases, the mount point should be treated much like a container
that uses a grouping.  The flags should also be set based on the
&apos;config&apos; leaf mentioned above, and the mount realted options indicated
above should be shown.  For example, the following represents
the prior example with YANG Routing and OSPF modules mounted, YANG
Interface module nodes accessible via a parent-reference, and
&apos;config&apos; indicating true:
    </t>
	<figure>
	    <artwork><![CDATA[
    module: ietf-network-instance
      +--rw network-instances
         +--rw network-instance* [name]
            +--rw name           string
            +--rw enabled?       boolean
            +--rw description?   string
            +--rw (ni-type)?
            +--rw (root-type)?
               +--:(vrf-root)
                  +--mp vrf-root?
                     +--ro rt:routing-state/
                     |  ...
                     +--rw rt:routing/
                     |  ...
                     +--ro if:interfaces@
                     |  ...
                     +--ro if:interfaces-state@
                        ...
	    ]]></artwork>
	</figure>
    <t>
The with &apos;config&apos; indicating false, the only change would be to the flag
on the rt:routing node:
    </t>
	<figure>
	    <artwork><![CDATA[
                     +--ro rt:routing/
	    ]]></artwork>
	</figure>
</section>
<section title="IANA Considerations" anchor="iana-considerations">
    <t>
There are no IANA requests or assignments included in this document.
    </t>
</section>
</middle>
<back>

<references title="Informative References">

<?rfc include="reference.RFC.7223"?>
<?rfc include="reference.RFC.7950"?>
<?rfc include="reference.I-D.ietf-netmod-schema-mount.xml"?>

</references>
</back></rfc>
