fix warning + add doc script

This commit is contained in:
a-sansara 2018-08-06 16:57:20 +02:00 committed by a-Sansara
parent 6cad99df70
commit 3a6a3faf98
24 changed files with 134 additions and 60 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
build/
bin/
doc/

View File

@ -10,6 +10,8 @@ to load a subset of yaml files in the main yaml document.
the lib does not manage yet tag directives and tag values.
**pluie-yaml** use the ![libyaml c library](https://github.com/yaml/libyaml) (License MIT, many thanks to Kirill Simonov) to parse and retriew related yaml events.
![pluie-yaml](https://www.meta-tech.academy/img/pluie-yaml-imports2.png)
## License
GNU GPL v3
@ -41,7 +43,6 @@ you can use `./build.sh` to rebuild/install the **pluie-yaml** lib and compile s
## Api / Documentation
https://pluie.org/pluie-yaml-0.4/index.htm
(comming soon)
## Docker
@ -159,7 +160,7 @@ vala code :
#### via iterator
```
```vala
var config = new Yaml.Config (path);
var root = config.root_node ();
Iterator<Yaml.Node> it = root.iterator ();
@ -172,7 +173,7 @@ vala code :
#### other
```
```vala
if (!node.empty ()) {
Yaml.Node child = node.first();
of.action("loop throught mapping next sibling", child.name);
@ -185,7 +186,7 @@ vala code :
}
```
```
```vala
if (node.count () > 0) {
child = node.last();
of.action("loop throught mapping previous sibling", child.name);
@ -211,5 +212,7 @@ see samples files in ./samples directory
* ~~imports clause~~
* ~~fix nodes traversing~~
* ~~rewrite nodes classes~~
* ~~put doc online~~
* improve doc
* dumper
* manage tag directives & tag

View File

@ -2,7 +2,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml>
# @version : 0.3
# @version : 0.4
# @date : 2018
# @licence : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]>

56
resources/doc-scripts.js Normal file
View File

@ -0,0 +1,56 @@
/* markupwriter.vala
*
* Copyright (C) 2008-2009 Florian Brosch
*
* 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 USA
*
* Author:
* Florian Brosch <flo.brosch@gmail.com>
*/
function get_path (path) {
var pos = path.lastIndexOf ('/');
if (pos < 0) {
return '';
}
return path.substring (pos, -1) + '/';
}
function toggle_box (self, id) {
var element = document.getElementById (id);
if (element == null) {
return ;
}
var style = self.currentStyle || window.getComputedStyle (self, false);
var orig_path = /url[ \t]*\(('(.*)'|"(.*)")\)/.exec (style.backgroundImage)[1].slice(1, -1);
var orig_dir = get_path (orig_path);
if (element.style.display == 'block') {
element.style.display = 'none';
self.style.backgroundImage = "url('" + orig_dir + 'coll_open.svg' + "')";
} else {
element.style.display = 'block';
self.style.backgroundImage = "url('" + orig_dir + 'coll_close.svg' + "')";
}
}
window.onload = function() {
var nav = document.querySelector('.site_navigation');
nav.innerHTML = '<div id="nav_content">'+nav.innerHTML+'</div>';
var header = document.querySelector('.site_header');
var data = header.innerHTML.split("");
header.innerHTML = data[0] + (data[1] ? '<div align="right" style="padding-right:20px; font-size:18px;">'+data[1]+'</div>' : '');
}

4
resources/doc-style.css Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.3
* @version : 0.4
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>

View File

@ -1,7 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.3
* @version : 0.4
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>

View File

@ -1,7 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.3
* @version : 0.4
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>

View File

@ -1,7 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.3
* @version : 0.4
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>

View File

@ -1,7 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.3
* @version : 0.4
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>

View File

@ -1,7 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.3
* @version : 0.4
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>

View File

@ -1,7 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.3
* @version : 0.4
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>

View File

@ -32,7 +32,7 @@ using Pluie;
using Gee;
/**
* a class representing a mapping node
* abstract class representing a child node
*/
public abstract class Pluie.Yaml.AbstractChild : Yaml.AbstractNode
{
@ -107,7 +107,7 @@ public abstract class Pluie.Yaml.AbstractChild : Yaml.AbstractNode
/**
* stuff on changing parent node
* @param child the childto add
* @param levelUpdate flag indicating if update level is needed
*/
protected virtual bool on_change_parent (bool levelUpdate = true)
{

View File

@ -32,7 +32,7 @@ using Gee;
using Pluie;
/**
*
* abstract class representing a node
*/
public abstract class Pluie.Yaml.AbstractNode : Object
{
@ -58,8 +58,8 @@ public abstract class Pluie.Yaml.AbstractNode : Object
/**
* default Yaml.Node constructor
* @param parent the parent node
* @param type the NODE_TYPE of Yaml.Node to create
* @param name the node name
*/
public AbstractNode (Yaml.NODE_TYPE type = Yaml.NODE_TYPE.UNDEFINED, string? name = null)
{
@ -67,9 +67,9 @@ public abstract class Pluie.Yaml.AbstractNode : Object
}
/**
* constructor for standard Yaml.Node
* @param parent the parent node
* @param type the NODE_TYPE of Yaml.Node to create
* @param name the node name
* @param data the node data
*/
public AbstractNode.with_name (Yaml.NODE_TYPE type = Yaml.NODE_TYPE.UNDEFINED, string? name = null, string? data = null)
{
@ -81,7 +81,7 @@ public abstract class Pluie.Yaml.AbstractNode : Object
/**
* test if specifiyed node is current node
* @param child the Yaml.Node node to test
* @param node the Yaml.Node node to test
*/
public virtual bool same_node (Yaml.AbstractNode? node)
{

View File

@ -38,56 +38,51 @@ public interface Pluie.Yaml.Collection
{
/**
* retriew the child at index
* @param child
* @param index index of seached child
*/
public abstract Yaml.Node? item (int index);
/**
* check if contains specifyed child node
* @param child
* @param child the child to check
*/
public abstract bool contains (Yaml.Node child);
/**
* count children
* @param child
*/
public abstract int count ();
/**
* check if empty
* @param child
*/
public abstract bool empty ();
/**
* check if empty
* @param child
* get a Yaml.Node Iterator
*/
public abstract Gee.Iterator<Yaml.Node> iterator ();
/**
* retriew the first child
* @param child
*/
public abstract Yaml.Node? first ();
/**
* retriew the last child
* @param child
*/
public abstract Yaml.Node? last ();
/**
* retriew the next sibling of specifiyed child node
* @param child
* @param child the the reference child node
*/
public abstract Yaml.Node? child_next_sibling (Yaml.Node child);
/**
* retriew the previous sibling of specifiyed child node
* @param child
* @param child the the reference child node
*/
public abstract Yaml.Node? child_previous_sibling (Yaml.Node child);

View File

@ -108,7 +108,7 @@ public class Pluie.Yaml.Config
/**
* find node matching specifiyed keyPath
*/
public void get_imports ()
protected void get_imports ()
{
var node = this.get("^imports");
if (node != null) {
@ -137,6 +137,7 @@ public class Pluie.Yaml.Config
Yaml.Node? n = null;
Yaml.Config? conf = null;
foreach(var entry in this.paths.entries) {
of.keyval(entry.key, entry.value);
conf = new Yaml.Config(entry.value, this.displayFile);
sub = conf.loader.get_nodes ();
n = new Yaml.Mapping (root, entry.key);
@ -155,13 +156,13 @@ public class Pluie.Yaml.Config
private void update_var (Yaml.Node node, string path)
{
this.varmap.set ("path", path);
string? file = null;
foreach (var child in node.list) {
if (child.name[0] != IMPORTS_SPE) {
var val = child.first().data;
if (!Path.is_absolute (val)) {
val = Path.build_filename(path, val);
}
this.paths[(string)child.name] = val;
this.resolve_var (child.name, val);
}
}

View File

@ -55,7 +55,10 @@ public class Pluie.Yaml.Event
/**
* construct a Event
* @param path the path to load
* @param evtype the Yaml.EVT event
* @param line original yaml line of related event
* @param style original yaml style
* @param data data related to event
*/
public Event (Yaml.EVT evtype, int line=0, int? style=null, Gee.HashMap<string, string>? data=null)
{

View File

@ -32,7 +32,7 @@ using Gee;
using Pluie;
/**
* parent class representing a Yaml Node whenether was his type
* Finder class used to easily retriew Yaml.Node
*/
public class Pluie.Yaml.Finder : Object
{
@ -44,7 +44,7 @@ public class Pluie.Yaml.Finder : Object
/**
* default Yaml.Finder constructor
* @param default Yaml.Node context
* @param context default Yaml.Node context
*/
public Finder (Yaml.Node context)
{
@ -54,22 +54,24 @@ public class Pluie.Yaml.Finder : Object
/**
* find a specific child Yaml.Node corresponding to path definition
* path definition has two mode.
* default mode is Yaml.FIND_MODE.SQUARE_BRACKETS
* node's key name must be enclosed in square brackets
* sequence entry must be enclosed in curly brace
* ex : [grandfather][father][son]{2}
* default mode is Yaml.FIND_MODE.DOT
* - child mapping node are separated by dot :
* - sequence entry must be enclosed in curly brace
* ex : grandfather.father.son{2}.age
*
* other mode is Yaml.FIND_MODE.DOT
* child mapping node are separated by dot :
* ex : grandfather.father.son{2}
* other mode is Yaml.FIND_MODE.DOTSQUARE_BRACKETS
* - node's key name must be enclosed in square brackets
* - sequence entry must be enclosed in curly brace
* ex : [grandfather][father][son]{2}[age]
*
* @param path the definition to retriew the child node
* @param context the Yaml.Node context to operate
*/
public Yaml.Node? find (string path, Yaml.Node? context = null)
{
string search = this.find_path (path);
bool match = false;
Yaml.Node? node = context == null ? this.context : context;
Yaml.Mapping? m = null;
Regex reg = /(\[|\{)([^\]\}]*)(\]|\})/;
MatchInfo mi;
try {
@ -114,7 +116,7 @@ public class Pluie.Yaml.Finder : Object
* get a path definition depending of current Node.mode
* if path definition is Yaml.FIND_MODE.DOT the path is convert to a
* Yaml.FIND_MODE.SQUARE_BRACKETS path definition
* @path the path definition
* @param path the path definition
* @return the find path definition according to current Node.mode
*/
private string find_path (string path)
@ -142,7 +144,8 @@ public class Pluie.Yaml.Finder : Object
/**
* indicates if specifiyed MatchInfo is related to a mapping node only or a collection node
* @param mi
* @param mi used MathInfo
* @param mappingOnly flag indicates if mappu only
*/
private bool is_collection_path (MatchInfo mi, bool mappingOnly = false)
{

View File

@ -97,6 +97,7 @@ public class Pluie.Yaml.Mapping : Yaml.Node
/**
* add a child node to current collection (mapping or sequence) node
* @param child the Yaml.Node child to add
* @param levelUpdate flag indicating if update level is needed
*/
protected override void on_removed (Yaml.Node child, bool levelUpdate = true)
{
@ -108,7 +109,7 @@ public class Pluie.Yaml.Mapping : Yaml.Node
/**
* retriew a child node throught specifiyed index
* @param index index of searched child
* @param name name of searched child
* @return the child node
*/
public new Yaml.Node? item (string name)
@ -125,7 +126,7 @@ public class Pluie.Yaml.Mapping : Yaml.Node
/**
* clone current node
* @param the name of clone
* @param name the overrinding name
*/
public override Yaml.Node clone_node (string? name = null)
{

View File

@ -31,12 +31,12 @@ using GLib;
using Gee;
/**
* a class representing a mapping node
* a class representing a node
*/
public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
{
/**
* sequence collection for Yaml.NodeSequence node
* Yaml.Node collection
*/
public ArrayList<Yaml.Node> list { get; internal set; }
@ -46,6 +46,7 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
* default Yaml.Node constructor
* @param parent the parent node
* @param type the NODE_TYPE of Yaml.Node to create
* @param name the node name
*/
public Node (Yaml.Node? parent = null, Yaml.NODE_TYPE type = Yaml.NODE_TYPE.UNDEFINED, string? name = null)
{
@ -56,7 +57,7 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
/**
* add a child node to current collection (mapping or sequence) node
* @param child the Yaml.Node child to add
* @param node the Yaml.Node child to add
*/
public virtual bool add (Yaml.AbstractChild node)
{
@ -136,7 +137,7 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
/**
* check if current node contains the specifiyed child node
* @param child
* @param child the child to check
*/
public bool contains (Yaml.Node child) {
return !this.empty () && this.list.contains (child);
@ -145,7 +146,7 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
/**
* count childnodes
*/
public int count () {
public override int count () {
return !this.empty () ? this.list.size : 0;
}
@ -227,7 +228,7 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
/**
* clone current node
* @param the name of clone
* @param name the name of clone
*/
public virtual Yaml.Node clone_node (string? name = null)
{
@ -243,7 +244,7 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
/**
* clone current node
* @param the name of clone
* @param name the name of clone
*/
public virtual Yaml.Node get_cloned_instance (string? name = null)
{
@ -270,7 +271,7 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
/**
* get a presentation string of current Yaml.Node
*/
public string to_string (bool withIndent = Yaml.DBG_SHOW_INDENT, bool withParent = Yaml.DBG_SHOW_PARENT, bool withUuid = Yaml.DBG_SHOW_UUID, bool withLevel = Yaml.DBG_SHOW_LEVEL, bool withCount = Yaml.DBG_SHOW_COUNT, bool withRefCount = Yaml.DBG_SHOW_REF)
public override string to_string (bool withIndent = Yaml.DBG_SHOW_INDENT, bool withParent = Yaml.DBG_SHOW_PARENT, bool withUuid = Yaml.DBG_SHOW_UUID, bool withLevel = Yaml.DBG_SHOW_LEVEL, bool withCount = Yaml.DBG_SHOW_COUNT, bool withRefCount = Yaml.DBG_SHOW_REF)
{
return "%s%s%s%s%s%s%s%s%s".printf (
this.level == 0 ? "" : of.s_indent ((int8) (withIndent ? (this.level-1)*4 : 0)),

View File

@ -32,7 +32,7 @@ using Pluie;
using Gee;
/**
* a class representing a mapping node
* a class representing a Scalar node
*/
public class Pluie.Yaml.Scalar : Yaml.Node
{
@ -42,7 +42,7 @@ public class Pluie.Yaml.Scalar : Yaml.Node
/**
* default Yaml.Node constructor
* @param parent the parent node
* @param type the NODE_TYPE of Yaml.Node to create
* @param data the Scalar value
*/
public Scalar (Yaml.Node ? parent = null, string? data = null)
{
@ -52,7 +52,7 @@ public class Pluie.Yaml.Scalar : Yaml.Node
/**
* clone current node
* @param the name of clone
* @param name the overrinding name
*/
public override Yaml.Node clone_node (string? name = null)
{

View File

@ -135,7 +135,7 @@ public class Pluie.Yaml.Scanner
/**
* scan specifiyed file generated throught yaml.c
* @param optional file path to scan
* @param path optional file path to scan
*/
public bool run (string? path = null)
{

View File

@ -32,7 +32,7 @@ using Pluie;
using Gee;
/**
* a class representing a mapping node
* a class representing a sequence node
*/
public class Pluie.Yaml.Sequence : Yaml.Node
{
@ -40,7 +40,7 @@ public class Pluie.Yaml.Sequence : Yaml.Node
/**
* default Yaml.Node constructor
* @param parent the parent node
* @param type the NODE_TYPE of Yaml.Node to create
* @param name the node name
*/
public Sequence (Yaml.Node? parent = null, string? name = null)
{

6
valadoc.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
valadoc --package-name=pluie-yaml-0.4 --verbose --force --deps -o ./doc --pkg gee-0.8 --pkg gio-2.0 --pkg gobject-2.0 --pkg glib-2.0 --pkg pluie-echo-0.2 ./src/vala/Pluie/*.vala ./build/install.vala
rm doc/*.png
cp resources/doc-scripts.js ./doc/scripts.js
cp resources/doc-style.css ./doc/style.css