-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #748 from matuzalemsteles/GenerateAPIDocs
Generate API Documents
- Loading branch information
Showing
15 changed files
with
912 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: "Api" | ||
url: "/api/v2.0.0-rc.10" | ||
layout: false | ||
--- | ||
|
||
{namespace pageApiIndex} | ||
|
||
/** | ||
*/ | ||
{template .render} | ||
{@param page: ?} | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="refresh" content="0; URL='{$page.url}'"> | ||
</head> | ||
</html> | ||
{/template} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{namespace ElectricApi} | ||
|
||
{template .render} | ||
{@param apiData: ?} | ||
{@param project: ?} | ||
{@param site: ?} | ||
{@param? entityData: ?} | ||
|
||
<div class="api"> | ||
<script src="/js/bundles/electricApi.js"></script> | ||
<div class="navbar navbar-mobile navbar-expand-lg navbar-header"> | ||
<a class="navbar-brand d-flex" href="/"> | ||
<img class="logo mr-2" src="/images/clay_logo_w.png" alt="" /> | ||
<span class="title h1 font-weight-bold mb-0 p-1">{$site.title} </span> | ||
</a> | ||
|
||
<button class="navbar-toggler sidebar-toggler p-3" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | ||
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-bars"> | ||
<use xlink:href="/vendor/lexicon/icons.svg#bars" /> | ||
</svg> | ||
</button> | ||
</div> | ||
|
||
<nav class="sidebar-toggler-content sidenav-fixed sidenav-menu-slider" id="clay-sidebar"> | ||
<div class="sidebar sidebar-clay-site sidenav-menu d-flex flex-column"> | ||
<div class="sidebar-header"> | ||
<div class="navbar navbar-expand-lg navbar-header"> | ||
<a class="navbar-brand" href="/"> | ||
<img class="logo mr-2" src="/images/clay_logo_w.png" alt="{$site.title}" /> | ||
<span class="title">{$site.title} </span> | ||
<small>by Liferay</small> | ||
</a> | ||
<div class="btn-group"> | ||
<button aria-expanded="false" aria-haspopup="true" class="btn btn-sm btn-version dropdown-toggle" data-toggle="dropdown" type="button"> | ||
{$project.ref} | ||
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-caret-bottom ml-1"> | ||
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/vendor/lexicon/icons.svg#caret-bottom"></use> | ||
</svg> | ||
</button> | ||
<div class="dropdown-menu mt-2"> | ||
{foreach $ref in $project.refs} | ||
{let $classes kind="text"} | ||
dropdown-item | ||
{if $project.ref == $ref} | ||
{sp}active | ||
{/if} | ||
{/let} | ||
|
||
<a class="{$classes}" href="/api/{$ref}">{$ref}</a> | ||
{/foreach} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="sidebar-body mb-auto"> | ||
<div class="sidebar-search"> | ||
<div class="page-autocomplete"> | ||
<div class="form-group"> | ||
<div class="input-group"> | ||
<input autocomplete="off" class="form-control" name="query" placeholder="Search API" ref="input" type="text" aria-activedescendant="" aria-autocomplete="list" aria-haspopup="true" aria-owns="autocomplete-6" role="combobox"> | ||
<span class="input-group-addon"> | ||
<svg class="lexicon-icon"> | ||
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/vendor/lexicon/icons.svg#search"></use> | ||
</svg> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<ul class="nav nav-nested nav-pills nav-stacked"> | ||
{foreach $entity in $apiData} | ||
<li class="{if $entityData.name == $entity.name} active{/if}"> | ||
<a class="align-middle" href="/api/{$project.ref}/{$entity.name}.html"> | ||
<span>{$entity.name}</span> | ||
</a> | ||
</li> | ||
{/foreach} | ||
</ul> | ||
</div> | ||
<ul class="nav-icons"> | ||
<li class="d-block mb-3"> | ||
<a class="rounded-circle sticker sticker-secondary" href="https://github.com/liferay/clay/issues" target="_blank"> | ||
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-bars"> | ||
<use xlink:href="/vendor/lexicon/icons.svg#comments" /> | ||
</svg> | ||
</a> | ||
</li> | ||
<li class="d-block"> | ||
<a class="rounded-circle sticker sticker-secondary" href="https://github.com/liferay/clay" target="_blank"> | ||
<img class="lexicon-icon" src="/images/home/GitHub-Mark-64px.svg" alt=""> | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</nav> | ||
|
||
<div class="sidebar-offset"> | ||
<div class="clay-site-container container-fluid"> | ||
{if $entityData and $entityData.name} | ||
{call ElectricAPIEntities.render} | ||
{param entityData: $entityData /} | ||
{param project: $project /} | ||
{/call} | ||
{else} | ||
<div class="docs-home-top"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<h1 class="docs-home-top-title">{$project.ref}</h1> | ||
</div> | ||
</div> | ||
</div> | ||
{/if} | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
window.electricPageComponent = new pageComponent.default({lb} | ||
project: {lb} | ||
ref: '{$project.ref}', | ||
repo: '{$project.repo}', | ||
user: '{$project.user}' | ||
{rb} | ||
{rb}); | ||
</script> | ||
</div> | ||
{/template} |
140 changes: 140 additions & 0 deletions
140
packages/clayui.com/src/partials/ElectricAPIAutocomplete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
'use strict'; | ||
|
||
import {isServerSide} from 'metal'; | ||
import Ajax from 'metal-ajax'; | ||
import Autocomplete from 'metal-autocomplete'; | ||
import Component from 'metal-component'; | ||
import core from 'metal'; | ||
import Promise from 'metal-promise'; | ||
|
||
class ElectricAPIAutocomplete extends Component { | ||
attached() { | ||
if (isServerSide()) { | ||
return; | ||
} | ||
|
||
this.autocomplete = new Autocomplete({ | ||
autoBestAlign: false, | ||
data: this.search_.bind(this), | ||
format: this.format_.bind(this), | ||
inputElement: this.input, | ||
select: function(event) { | ||
window.location = event.url; | ||
} | ||
}); | ||
} | ||
|
||
disposed() { | ||
let autocomplete = this.autocomplete; | ||
|
||
if (autocomplete) { | ||
autocomplete.dispose(); | ||
} | ||
} | ||
|
||
format_(data) { | ||
let url = this.formatURL_(data); | ||
|
||
return { | ||
textPrimary: `<a class="autocomplete-link" href="${url}"> | ||
<div class="autocomplete-result"> | ||
<p class="autocomplete-title">${data.name}</p> | ||
<p class="autocomplete-text">${data.memberof}</p> | ||
</div> | ||
</a>`, | ||
url: url | ||
}; | ||
} | ||
|
||
formatURL_(data) { | ||
let memberof = data.memberof; | ||
let name = data.name; | ||
|
||
let url = `/api/${this.project.ref}/${memberof || name}.html`; | ||
|
||
if (memberof && name !== memberof) { | ||
url += '#' + name; | ||
} | ||
|
||
return url; | ||
} | ||
|
||
matchesQuery_(entity, query) { | ||
let name = entity.name; | ||
|
||
name = name ? name.toLowerCase() : ''; | ||
|
||
return name.indexOf(query) > -1; | ||
} | ||
|
||
filterResults_(data, query) { | ||
let instance = this; | ||
let results = []; | ||
|
||
data.forEach(function(entity) { | ||
if (instance.matchesQuery_(entity, query)) { | ||
results.push(entity); | ||
} | ||
|
||
if (entity.members) { | ||
results = results.concat(instance.filterResults_(entity.members.instance, query)); | ||
results = results.concat(instance.filterResults_(entity.members.static, query)); | ||
} | ||
}); | ||
|
||
return results; | ||
} | ||
|
||
search_(query) { | ||
let instance = this; | ||
|
||
return Promise.resolve(this.data) | ||
.then(function(data) { | ||
if (data) { | ||
return data; | ||
} | ||
else { | ||
return Ajax.request(instance.dataSource) | ||
} | ||
}) | ||
.then(function(data) { | ||
if (data.response) { | ||
data = JSON.parse(data.response); | ||
|
||
instance.data = data; | ||
} | ||
|
||
let results = []; | ||
|
||
if (data && query) { | ||
results = instance.filterResults_(data, query.toLowerCase()); | ||
|
||
if (results.length > instance.maxResults) { | ||
results = results.slice(0, instance.maxResults); | ||
} | ||
} | ||
|
||
return results; | ||
}); | ||
} | ||
} | ||
|
||
ElectricAPIAutocomplete.STATE = { | ||
dataSource: { | ||
validator: core.isString | ||
}, | ||
|
||
maxResults: { | ||
validator: core.isNumber | ||
}, | ||
|
||
project: { | ||
validator: core.isObject | ||
}, | ||
|
||
input: { | ||
validator: core.isElement | ||
} | ||
}; | ||
|
||
export default ElectricAPIAutocomplete; |
Oops, something went wrong.