github.com/openconfig/goyang@v1.4.5/pkg/yang/doc.go (about)

     1  // Copyright 2015 Google Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package yang is used to parse .yang files (see RFC 6020).
    16  //
    17  // A generic yang statements takes one of the forms:
    18  //
    19  //	keyword [argument] ;
    20  //	keyword [argument] { [statement [...]] }
    21  //
    22  // At the lowest level, package yang returns a simple tree of statements via the
    23  // Parse function.  The Parse function makes no attempt to determine the
    24  // validity of the source, other than checking for generic syntax errors.
    25  //
    26  // At it's simplest, the GetModule function is used.  The GetModule function
    27  // searches the current directory, and any directory added to the Path variable,
    28  // for a matching .yang source file by appending .yang to the name of the
    29  // module:
    30  //
    31  //	// Get the tree for the module module-name by looking for the source
    32  //	// file named module-name.yang.
    33  //	e, errs := yang.GetModule("module-name" [, optional sources...])
    34  //	if len(errs) > 0 {
    35  //		for _, err := range errs {
    36  //			fmt.Fprintln(os.Stderr, err)
    37  //		}
    38  //		os.Exit(1)
    39  //	}
    40  //
    41  //	// e is the Entry tree for "module-name"
    42  //
    43  // More complicated uses cases should use NewModules and then some combination
    44  // of Modules.GetModule, Modules.Read, Modules.Parse, and Modules.GetErrors.
    45  //
    46  // The GetErrors method is mandatory, however, both yang.GetModule and
    47  // Modules.GetModule automatically call Modules.GetErrors.
    48  package yang