Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
cope with missing description property, and add in namespace for all …
Browse files Browse the repository at this point in the history
…assets (#4193)

Signed-off-by: Matthew B White <[email protected]>
  • Loading branch information
mbwhite authored and cazfletch committed Jun 27, 2018
1 parent 4473d27 commit 6026152
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
limitations under the License.
#}
# Asset Model

{% for asset in types.asset %}
{% for id,assets in types.asset %}
{% for asset in assets %}
#### {{asset.name}}
**{{asset.fqn}}** - **{{asset.description}}**

Expand All @@ -27,6 +27,7 @@
{% endfor %}

{% endfor %}
{% endfor %}



Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
limitations under the License.
#}
# Enumeration Detail

{% for enum in types.enum %}
{% for id,enums in types.enum %}
{% for enum in enums %}
### {{enum.name}}
The fully qualified name is **{{enum.fqn}}**

Expand All @@ -31,3 +31,4 @@ The fully qualified name is **{{enum.fqn}}**
{% endfor %}

{% endfor %}
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
limitations under the License.
#}
# Events Detail

{% for evt in types.event %}
{% for id,evts in types.event %}
{% for evt in evts %}
### {{evt.name}}
The fully qualified name is **{{evt.fqn}}**

Expand All @@ -31,3 +31,4 @@ The fully qualified name is **{{evt.fqn}}**
{% endfor %}

{% endfor %}
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@
## Asset Definition
| Namespace | Name | Description |
| -------- | ---- | ----------- |
{% for asset in types.asset %}| {{asset.fqn}} | {{asset.name}} | {{asset.description}} |
{% endfor %}
{% for id,assets in types.asset %}{% for asset in assets %}| {{asset.fqn}} | {{asset.name}} | {{asset.description}} |
{% endfor %}{% endfor %}


## Transaction Definition
| Namespace | Name | Description |
| -------- | ---- | ----------- |
{% for tx in types.transaction %}| {{tx.fqn}} | {{tx.name}} | {{tx.description}} |
{% endfor %}
{% for id,transactions in types.transaction %}{% for tx in transactions %}| {{tx.fqn}} | {{tx.name}} | {{tx.description}} |
{% endfor %}{% endfor %}

## Participant Definition
| Namespace | Name | Description |
| -------- | ---- | ----------- |
{% for pt in types.participant %}| {{pt.fqn}} | {{pt.name}} | {{pt.description}} |
{% endfor %}
{% for id,participants in types.participant %}{% for pt in participants %}| {{pt.fqn}} | {{pt.name}} | {{pt.description}} |
{% endfor %}{% endfor %}


## ACL
{% for rule in acls %}- {{rule.description}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
limitations under the License.
#}
# Particpant Model

{% for pt in types.participant %}
{% for id,pts in types.participant %}
{% for pt in pts %}
#### {{pt.name}}
**{{pt.fqn}}** - **{{pt.description}}**

Expand All @@ -22,5 +22,5 @@
{% for id,info in pt.properties %}|{{id}}|{{info.type}}|{{info.description}}|
{% endfor %}
{% endfor %}

{% endfor %}

Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@
<nav class="context-nav">
<ul>
{% if 'assets' in basename %}
{% for asset in types.asset %}
{% for id,assets in types.asset%}
{% for asset in assets %}
<li><p><a href="#{{asset.name | lower}}"><b>{{asset.name}}</b></a></p></li>
{% endfor %}
{% endfor %}
{% elif 'transactions' in basename %}
{% for fn in scripts.files %}
<li><p><a href="#{{fn.identifier | lower}}"><b>{{fn.identifier}}</b></a></p>
Expand All @@ -97,9 +99,11 @@
{% elif 'index' in basename %}

{% elif 'participants' in basename %}
{% for pt in types.participant %}
{% for id,pts in types.participant %}
{% for pt in pts %}
<li><p><a href="#{{pt.name | lower}}"><b>{{pt.name}}</b></a></p></li>
{% endfor %}
{% endfor %}
{% elif 'queries' in basename %}
{% for query in queries %}
<li><p><a href="#{{query.name | lower | replace("_","-") }}"><b>{{query.name }}</b></a></p></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
## Asset Definition
| Namespace | Name | Description |
| -------- | ---- | ----------- |
{% for asset in types.asset %}| {{asset.fqn}} | {{asset.name}} | {{asset.description}} |
{% endfor %}
{% for id,assets in types.asset %}
{% for asset in assets %}| {{asset.fqn}} | {{asset.name}} | {{asset.description}} |
{% endfor %}{% endfor %}


## Transaction Definition
| Namespace | Name | Description |
| -------- | ---- | ----------- |
{% for tx in types.transaction %}| {{tx.fqn}} | {{tx.name}} | {{tx.description}} |
{% endfor %}
{% for id,transactions in types.transaction %}{% for tx in transactions %}| {{tx.fqn}} | {{tx.name}} | {{tx.description}} |
{% endfor %}{% endfor %}

## Participant Definition
| Namespace | Name | Description |
| -------- | ---- | ----------- |
{% for pt in types.participant %}| {{pt.fqn}} | {{pt.name}} | {{pt.description}} |
{% endfor %}
{% for id,participants in types.participant %}{% for pt in participants %}| {{pt.fqn}} | {{pt.name}} | {{pt.description}} |
{% endfor %}{% endfor %}


Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#}
# Asset Model

{% for asset in types.asset %}
{% for id,assets in types.asset %}
{% for asset in assets %}
## {{asset.name}}
The fully qualified name is **{{asset.fqn}}**

Expand All @@ -38,4 +39,4 @@ The fully qualified name is **{{asset.fqn}}**
{% if asset.decorators.docsuri %}
[{{asset.decorators.docsuri[0]}}]({{asset.decorators.docsuri[1]}})
{% endif %}
{% endfor %}
{% endfor %}{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
limitations under the License.
#}
# Participant Model

{% for pt in types.participant %}
{% for id,participants in types.participant %}
{% for pt in participants %}
### {{pt.name}}
The fully qualified name is **{{pt.fqn}}**

Expand All @@ -32,3 +32,4 @@ The fully qualified name is **{{pt.fqn}}**


{% endfor %}
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
limitations under the License.
#}
# Transaction Functions Detail

{% for tx in types.transaction %}
{% for id,transactions in types.transaction %}
{% for tx in transactions %}
### {{tx.name}}
The fully qualified name is **{{tx.fqn}}**

Expand All @@ -30,4 +30,4 @@ The fully qualified name is **{{tx.fqn}}**
{% for id,info in tx.properties %}| {{id}} | {{info.type}} | {{info.description}} |
{% endfor %}

{% endfor %}
{% endfor %}{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
limitations under the License.
#}
# Events Detail

{% for evt in types.event %}
{% for id,events in types.event%}
{% for evt in events %}
### {{evt.name}}
The fully qualified name is **{{evt.fqn}}**

Expand All @@ -30,4 +30,4 @@ The fully qualified name is **{{evt.fqn}}**
{% for id,info in evt.properties %}| {{id}} | {{info.type}} | {{info.description}} |
{% endfor %}

{% endfor %}
{% endfor %}{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
limitations under the License.
#}
# Enumeration Detail

{% for enum in types.enum %}
{% for id,enums in types.enum %}
{% for enum in enums %}
### {{enum.name}}
The fully qualified name is **{{enum.fqn}}**

Expand All @@ -30,4 +30,4 @@ The fully qualified name is **{{enum.fqn}}**
{% for id,info in enum.properties %}| {{id}} |
{% endfor %}

{% endfor %}
{% endfor %}{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ function tagMerge(resource,tags){
if (tags[t].title === 'param'){
let desc = tags[t].description;
let name = tags[t].name;
resource.properties[name].description = desc;
if (resource.properties[name]){
resource.properties[name].description = desc;
}
}
}

Expand Down Expand Up @@ -64,23 +66,30 @@ function classdeclarations(context,options){

['asset','concept','transaction','enum','participant','event'].forEach((t)=>{
// need to added the parsed comments to the existing structure
for (let i=0; i<context.types[t].length;i++){
let resource = context.types[t][i];
if (data[resource.fqn]){
context.types[t][i].tags= data[resource.fqn].tags;
tagMerge(context.types[t][i],data[resource.fqn].tags);
}

// if there are decorators referring to a markdown file, load that in as well
let decorators = context.types[t][i].decorators;
if (decorators.docs){
for (let d = 0; d< decorators.docs.length;d++){
let name = path.resolve(options.docsPrefix,decorators.docs[d]);
let info = fs.readFileSync(name,'utf8');
context.types[t][i].decorators[decorators.docs[d]] = info;
// context.types[t] gives an object whose keys are namespaces
let namespaces = Object.keys(context.types[t]);
namespaces.forEach((ns)=>{

let typesArray = context.types[t][ns];
for (let i=0; i<typesArray.length;i++){
let resource = typesArray[i];
if (data[resource.fqn]){
typesArray[i].tags= data[resource.fqn].tags;
tagMerge(typesArray[i],data[resource.fqn].tags);
}

// if there are decorators referring to a markdown file, load that in as well
let decorators = typesArray[i].decorators;
if (decorators.docs){
for (let d = 0; d< decorators.docs.length;d++){
let name = path.resolve(options.docsPrefix,decorators.docs[d]);
let info = fs.readFileSync(name,'utf8');
typesArray[i].decorators[decorators.docs[d]] = info;
}
}
}
}
});
});

return context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let process = async function(context,options){

// run standard Composer Introspector
let visitor = new InfoVisitor();
context.types = { asset: [], transaction: [], concept: [], enum: [], participant: [], event: [] };
context.types = { asset: {}, transaction: {}, concept: {}, enum: {}, participant: {}, event: {} };
context._bnd.accept(visitor, { data: context.types, ctx: context, system: options.systemns });

// run specific generators now to add extra information and structure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ class InfoVisitor {
// If this is a top level schema, now we need to write it to disk.
if (jsonSchema.$schema) {

// let fileName = `${classDeclaration.getFullyQualifiedName()}.json`;
// let fileName = `${classDeclaration.getFullyQualifiedName()}.json`;
let newInfo = {
'fqn': classDeclaration.getFullyQualifiedName(),
'name': jsonSchema.title,
Expand All @@ -465,8 +465,11 @@ class InfoVisitor {
'allproperties' :jsonSchema.allproperties,
'decorators': jsonSchema.decorators
};

parameters.data[jsonSchema.type].push(newInfo);
let ns = classDeclaration.getNamespace();
if (!parameters.data[jsonSchema.type][ns]){
parameters.data[jsonSchema.type][ns]=[];
}
parameters.data[jsonSchema.type][ns].push(newInfo);
}

// Return the created schema.
Expand Down
Binary file modified packages/composer-documentation/test/carauction-network.bna
Binary file not shown.

0 comments on commit 6026152

Please sign in to comment.