Skip to content

Commit

Permalink
initial work on documentation using typedoc from https://github.com/s…
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoranders committed Mar 31, 2015
1 parent 108472e commit de92b69
Show file tree
Hide file tree
Showing 21 changed files with 364 additions and 9 deletions.
5 changes: 4 additions & 1 deletion app/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Arts = require("./components/arts/Arts");

import SetupComponent = require('./components/setup/Setup');
import DocsComponent = require('./components/docs/Docs');

class ApplicationConfiguration extends Arts.BaseApplicationConfiguration {

Expand Down Expand Up @@ -38,7 +39,8 @@ class Application extends Arts.BaseApplication {
static NAME:string = 'com.github.gregoranders.arts';

static DEPENDENCIES:Array<string> = [
SetupComponent.NAME
SetupComponent.NAME,
DocsComponent.NAME
];

constructor(baseURL:string) {
Expand All @@ -51,6 +53,7 @@ class Application extends Arts.BaseApplication {
var components:Arts.IModule[] = [];

components.push(SetupComponent.initializeComponents(basePath + 'components/setup/'));
components.push(DocsComponent.initializeComponents(basePath + 'components/docs/'));

return components;
}
Expand Down
3 changes: 2 additions & 1 deletion app/components/arts/BaseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class BaseService implements IService {

protected _name:string = BaseService.NAME;

constructor() {
constructor(name:string) {
this._name = name;
}

name():string {
Expand Down
3 changes: 1 addition & 2 deletions app/components/arts/BaseService.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class TestClass extends BaseService {
static NAME:string = 'test123';

constructor() {
super();
this._name = TestClass.NAME;
super(TestClass.NAME);
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/components/arts/l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"about": {
"setupandinstall": "Einrichtung und Installation",
"setup": "Einrichtung",
"installation": "Installation"
"installation": "Installation",
"documentation": "Dokumentation"
},
"generic": {
"refresh": "Aktualisieren",
Expand Down
3 changes: 2 additions & 1 deletion app/components/arts/l10n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"about": {
"setupandinstall": "Setup and installation",
"setup": "Setup",
"installation": "Installation"
"installation": "Installation",
"documentation": "Documentation"
},
"generic": {
"refresh": "Refresh",
Expand Down
3 changes: 2 additions & 1 deletion app/components/arts/l10n/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"about": {
"setupandinstall": "Konfiguracja i instalacja",
"setup": "Konfiguracja",
"installation": "Instalacja"
"installation": "Instalacja",
"documentation": "Dokumentacja"
},
"generic": {
"refresh": "Odświeżyć",
Expand Down
3 changes: 2 additions & 1 deletion app/components/arts/l10n/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"about": {
"setupandinstall": "Установка и монтаж",
"setup": "Установка",
"installation": "монтаж"
"installation": "монтаж",
"documentation": "документация"
},
"generic": {
"refresh": "обновление",
Expand Down
5 changes: 5 additions & 0 deletions app/components/docs/Component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export var NAME:string = 'com.github.gregoranders.arts.docs';

export var SERVICE: string = NAME + '.service';

export var VERSION:string = '0.0.1';
62 changes: 62 additions & 0 deletions app/components/docs/Docs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import Arts = require("../arts/Arts");

import IndexController = require("./controller/IndexController");
import DocsService = require("./service/DocsService");
import Component = require("./Component");

class ModuleConfiguration extends Arts.BaseConfiguration {

static NAME:string = Component.NAME + '.configuration';

static $inject:Array<string> = [
'$routeProvider',
'$controllerProvider',
'$provide',
'$compileProvider',
'$translateProvider',
'$translatePartialLoaderProvider'
];

constructor(protected $routeProvider:angular.route.IRouteProvider,
protected $controllerProvider:angular.IControllerProvider,
protected $provideService:ng.auto.IProvideService,
protected $compileProvider:ng.ICompileProvider,
protected $translateProvider:ng.translate.ITranslateProvider,
protected $translatePartialLoaderProvider:ng.translate.ITranslatePartialLoaderService) {

super($routeProvider, $controllerProvider, $provideService, $compileProvider, $translateProvider);

var component:Arts.IApplication = <Arts.IApplication>Arts.Arts.getModule(DocsComponent.NAME)
.initModule($routeProvider, $controllerProvider, $provideService, $compileProvider),
basePath = component.getBaseURL();

// routing
super.when('/docs', {
name: 'docs',
templateUrl: basePath + 'view/main.html',
controller: IndexController
});

$translatePartialLoaderProvider.addPart('docs');

component.service(<any>DocsService);
}
}

class DocsComponent extends Arts.BaseModule {

static NAME:string = Component.NAME;

static DEPENDENCIES:Array<string> = ['pascalprecht.translate'];

constructor(baseURL:string) {
super(DocsComponent.NAME, baseURL, DocsComponent.DEPENDENCIES, ModuleConfiguration);
Arts.Arts.registerModule(DocsComponent.NAME, this);
}

static initializeComponents(basePath:string):DocsComponent {
return new DocsComponent(basePath);
}
}

export = DocsComponent;
92 changes: 92 additions & 0 deletions app/components/docs/controller/IndexController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import Arts = require('../../arts/Arts');
import Component = require('../Component');
import IDocsService = require('../service/IDocsService');
import Model = require('../model/IDocsModel');

interface IScope extends Arts.IScope<IController> {

}

interface IController extends Arts.IController<IScope> {

selectedTabIndex: number;
docs: Model.IDocs;
documentation: any;

toggleSideBar(id:string): void;

switchToTab(group:Model.IDocsGroup): void;
}

class IndexController extends Arts.BaseController<IScope> implements IController {

static $inject:string[] = ['$scope', '$mdSidenav', '$mdToast', '$mdBottomSheet', Component.SERVICE];

selectedTabIndex:number = 0;

bottomSheetPromise:ng.IPromise<void>;

docs:Model.IDocs = null;

documentation: any = {
classes: null
};

private baseURL:string;

constructor(public $scope:IScope, private $mdSidenav:ng.material.MDSidenavService,
private $mdToast:ng.material.MDToastService,
private $mdBottomSheet:ng.material.MDBottomSheetService,
private IDocsService:IDocsService) {
super($scope);

var component:Arts.IApplication = <Arts.IApplication>Arts.Arts.getModule(Component.NAME);

this.baseURL = component.getBaseURL();

IDocsService.getDocs()
.success((data:any):void => {
this.docs = data;
})
.error((data:any):void => {
console.log(data);
})
}

toggleSideBar(id:string):void {
this.$mdSidenav(id).toggle();
}

switchToTab(group:Model.IDocsGroup):void {

var obj: any = [];

this.documentation = {};

angular.forEach(group.children, (element: number) => {
var def = this.findObjectById(element, this.docs);

if (def) {
obj.push(def);
}
});

this.documentation.classes = obj;
this.selectedTabIndex = this.docs.groups.indexOf(group);
this.$mdSidenav('left').close();
}

findObjectById(id: number, docs: Model.IDocs): Model.IDocBaseId {
var retval: Model.IDocBaseId = null;
angular.forEach(docs.children, (element: Model.IDocBaseId): void => {
if (element.id === id) {
retval = element;
return;
}
});

return retval;
}
}

export = IndexController;
13 changes: 13 additions & 0 deletions app/components/docs/l10n/de_DE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"com": {
"github": {
"gregoranders": {
"arts": {
"docs": {
"documentation": "Dokumentation"
}
}
}
}
}
}
13 changes: 13 additions & 0 deletions app/components/docs/l10n/en_US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"com": {
"github": {
"gregoranders": {
"arts": {
"docs": {
"documentation": "Documentation"
}
}
}
}
}
}
13 changes: 13 additions & 0 deletions app/components/docs/l10n/pl_PL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"com": {
"github": {
"gregoranders": {
"arts": {
"docs": {
"documentation": "Dokumentacja"
}
}
}
}
}
}
13 changes: 13 additions & 0 deletions app/components/docs/l10n/ru_RU.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"com": {
"github": {
"gregoranders": {
"arts": {
"docs": {
"documentation": "документация"
}
}
}
}
}
}
30 changes: 30 additions & 0 deletions app/components/docs/model/IDocsModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

export interface IDocBaseKind {
kind: number;
}

export interface IDocBaseId extends IDocBaseKind {
id: number;
}

export interface IDocBase extends IDocBaseId {
name: string;
}

export interface IDocs extends IDocBase {
groups: IDocsGroups;
children: IDocsChildren;
}

export interface IDocsGroups extends Array<IDocsGroup> {
[index: number]: IDocsGroup;
}

export interface IDocsChildren extends Array<IDocBaseId> {
[index: number]: IDocBaseId;
}

export interface IDocsGroup extends IDocBaseKind {
title: string;
children: any;
}
28 changes: 28 additions & 0 deletions app/components/docs/service/DocsService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Arts = require('../../arts/Arts');
import IDocsService = require('./IDocsService');
import Component = require('../Component');
import Model = require('../model/IDocsModel');

class DocsService extends Arts.BaseService implements IDocsService {
/**
* Class name.
*
* @type {string}
*/
static NAME:string = Component.SERVICE;

static $inject:Array<string> = ['$http'];

constructor(private $http:ng.IHttpService) {
super(DocsService.NAME);
}

getDocs():ng.IHttpPromise<Model.IDocs> {
var component:Arts.IApplication = <Arts.IApplication>Arts.Arts.getModule(Component.NAME),
basePath = component.getBaseURL();

return this.$http.get(basePath + 'l10n/docs.json');
}
}

export = DocsService;
9 changes: 9 additions & 0 deletions app/components/docs/service/IDocsService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Arts = require('../../arts/Arts');
import Component = require('../Component');
import Model = require('../model/IDocsModel');

interface IDocsService extends Arts.IService {
getDocs(): ng.IHttpPromise<Model.IDocs>;
}

export = IDocsService;

0 comments on commit de92b69

Please sign in to comment.