Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsonschema2md
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fork
jsonschema2md
Commits
d27cb8c7
Commit
d27cb8c7
authored
8 years ago
by
Stefan Guggisberg
Browse files
Options
Downloads
Patches
Plain Diff
cleaned and simplified code
parent
ed04b675
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/main.js
+2
-2
2 additions, 2 deletions
lib/main.js
lib/schema.js
+7
-12
7 additions, 12 deletions
lib/schema.js
templates/class.ejs
+20
-26
20 additions, 26 deletions
templates/class.ejs
templates/schema.ejs
+1
-1
1 addition, 1 deletion
templates/schema.ejs
with
30 additions
and
41 deletions
lib/main.js
+
2
−
2
View file @
d27cb8c7
...
...
@@ -60,8 +60,8 @@ function generateHtml(schema, cb) {
var
ctx
=
{
model
:
schema
.
getModel
(),
consts
:
consts
,
_
:
_
,
uriToPrefixesMap
:
schema
.
getURIToPrefixesMap
()
prefixes
:
schema
.
getPrefixMap
()
,
_
:
_
};
ejs
.
renderFile
(
'
./templates/schema.ejs
'
,
ctx
,
function
(
err
,
str
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/schema.js
+
7
−
12
View file @
d27cb8c7
...
...
@@ -129,15 +129,8 @@ Schema.load = function (schemaFile, cb) {
callback
(
new
Error
(
'
Parsing
'
+
schemaFile
+
'
failed
'
));
return
;
}
var
prefixes
=
{};
var
uriToPrefixesMap
=
{};
_
.
forOwn
(
turtleParser
.
environment
.
prefixes
,
function
(
value
,
key
)
{
prefixes
[
key
]
=
value
;
uriToPrefixesMap
[
value
]
=
key
;
});
var
doc
=
{
graph
:
graph
,
prefixes
:
prefixes
,
uriToPrefixesMap
:
uriToP
refixes
Map
};
var
doc
=
{
graph
:
graph
,
prefixes
:
turtleParser
.
environment
.
p
refixes
};
callback
(
null
,
doc
);
}
...
...
@@ -259,12 +252,14 @@ Schema.prototype.getModel = function () {
};
/**
* Returns the Prefix Map.
* Returns the prefix map, in instance of the <code>PrefixMap</code> RDF Interface.
*
* @see https://www.w3.org/TR/2012/NOTE-rdf-interfaces-20120705/#prefix-maps
*
* @return {
prefixes
} prefix map object
* @return {
Object
} prefix map object
*/
Schema
.
prototype
.
get
URITo
Prefix
es
Map
=
function
()
{
return
this
.
_rdfDoc
.
uriToP
refixes
Map
;
Schema
.
prototype
.
getPrefixMap
=
function
()
{
return
this
.
_rdfDoc
.
p
refixes
;
};
/**
...
...
This diff is collapsed.
Click to expand it.
templates/class.ejs
+
20
−
26
View file @
d27cb8c7
...
...
@@ -28,32 +28,26 @@
<br>
<div style = "font-size:large"><b>Properties:</b></div>
<div class=" table " data-dist-id="table_246994025">
<table width="100%" cellspacing="0" cellpadding="1" border="1">
<thead><tr><th>Name </th>
<th>Json Name </th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tbody>
<% _.forEach(clazz.properties, function (prop) { %>
<tr>
<td align = "center"><b>
<% var cond = prop["@id"].lastIndexOf('#') %>
<% if(cond !== -1) { %>
<%- uriToPrefixesMap[prop["@id"].substring(0,prop["@id"].lastIndexOf('#')+1)] %>:
<%- prop["@id"].substring(prop["@id"].lastIndexOf('#')+1) %>
<% } else { %>
<%- uriToPrefixesMap[prop["@id"].substring(0,prop["@id"].lastIndexOf('/')+1)] %>:
<%- prop["@id"].substring(prop["@id"].lastIndexOf('/')+1) %>
<% } %></b>
</td>
<td><%- prop[consts.META_JSONNAME] %></td>
<td><%- model.datatypes[prop[consts.RDFS_RANGE]][consts.RDFS_LABEL] %> </td>
<td><%- prop[consts.RDFS_COMMENT] %></td>
</tr>
<% }); %>
</tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="1" border="1">
<thead>
<tr>
<th>Name</th>
<th>JSON Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<% _.forEach(clazz.properties, function (prop) { %>
<tr>
<td align = "center"><b><%- prefixes.shrink(prop["@id"]) %></b></td>
<td><%- prop[consts.META_JSONNAME] %></td>
<td><%- model.datatypes[prop[consts.RDFS_RANGE]][consts.RDFS_LABEL] %></td>
<td><%- prop[consts.RDFS_COMMENT] %></td>
</tr>
<% }); %>
</tbody>
</table>
</div>
</li>
This diff is collapsed.
Click to expand it.
templates/schema.ejs
+
1
−
1
View file @
d27cb8c7
...
...
@@ -121,7 +121,7 @@
<h2><u>
Classes
</u></h2>
<ul>
<
%
_.forEach
(
model.classes
,
function
(
clazz
)
{
%
>
<
%
-
include
('
class
',
{
clazz:
clazz
,
model:
model
,
consts:
consts
,
uriToPrefixesMap:uriToP
refixes
Map
});
%
>
<
%
-
include
('
class
',
{
clazz:
clazz
,
model:
model
,
consts:
consts
,
_:
_
,
prefixes:
p
refixes
});
%
>
<br>
<
%
});
%
>
</ul>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment