Skip to content

Commit

Permalink
Added style
Browse files Browse the repository at this point in the history
  • Loading branch information
remojansen committed Nov 17, 2016
1 parent 4341524 commit 7dd6dde
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 2016 MVP Global Summit Hackathon
This VS Code extension was developed during a hackathon at the 2016 MVP Global Summit. This extension allows you to auto-generate UML diagrams for TypeScript applications:

![](preview.gif)
![](/assets/preview.gif)

## About this repo
Please do not expect this to be a production-ready extension: **IT IS JUST AN EXPERIMENT**.
Expand Down
File renamed without changes
File renamed without changes
Binary file added assets/yUML.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/core/interfaces/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ module interfaces {
name: string;
props: PropDetails[];
methods: MethodDetails[];
relationships: EntityRelationShip[];
}

export type EntityRelationshipKind = "implementation" | "extension" | "composition";

export interface EntityRelationShip {
kind: EntityRelationshipKind;
left: EntityDetails;
right: EntityDetails;
link: string;
}

}
Expand Down
3 changes: 3 additions & 0 deletions src/core/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ function parse(fileNames: string[], options: ts.CompilerOptions): interfaces.Ent
methods: [],
name: symbol.getName(),
props: [],
relationships: [
{ kind: "extension", link: "B" }
]
};

EntityDetails.props = serializeProperties(symbol);
Expand Down
62 changes: 37 additions & 25 deletions src/core/serializer/serializer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import interfaces from "../interfaces/interfaces";

// DSL docs at http://yuml.me/

function endFactory(separator: string, defaultSeparator = ``) {
return (index: number, collection: any[]) => {
let isLastElement = (index === (collection.length - 1));
Expand Down Expand Up @@ -30,43 +32,46 @@ function serializeMethods(methodsDetails: interfaces.MethodDetails[]) {
}).reduce((prev, val) => prev + val, "");
}

function serializeClass(EntityDetails: interfaces.EntityDetails) {
let props = serializeProps(EntityDetails.props);
let methods = serializeMethods(EntityDetails.methods);
return `[${EntityDetails.name}|${props}|${methods}{bg:steelblue}]\n`;
function serializeClass(entityDetails: interfaces.EntityDetails) {
let props = serializeProps(entityDetails.props);
let methods = serializeMethods(entityDetails.methods);
return `[${entityDetails.name}|${props}|${methods}{bg:steelblue}],`;
}

function serializeInterface(EntityDetails: interfaces.EntityDetails) {
let props = serializeProps(EntityDetails.props);
let methods = serializeMethods(EntityDetails.methods);
return `[${EntityDetails.name}|${props}|${methods}{bg:wheat}]\n`;
function serializeInterface(entityDetails: interfaces.EntityDetails) {
let props = serializeProps(entityDetails.props);
let methods = serializeMethods(entityDetails.methods);
return `[${entityDetails.name}|${props}|${methods}{bg:wheat}],`;
}

function serializeAbstractClass(EntityDetails: interfaces.EntityDetails) {
let props = serializeProps(EntityDetails.props);
let methods = serializeMethods(EntityDetails.methods);
return `[${EntityDetails.name}|${props}|${methods}{bg:plum}]\n`;
function serializeAbstractClass(entityDetails: interfaces.EntityDetails) {
let props = serializeProps(entityDetails.props);
let methods = serializeMethods(entityDetails.methods);
return `[${entityDetails.name}|${props}|${methods}{bg:plum}],`;
}

function serializeInheritanceRelationships(EntityDetails: interfaces.EntityDetails) {
// TODO
return "[CHILD]^-.-[PARENT]";
function serializeInheritanceRelationships(entityDetails: interfaces.EntityDetails) {
return entityDetails.relationships
.filter((relationship) => relationship.kind === "extension")
.map((relationship) => `[${entityDetails.name}]^-[${relationship.link}],`);
}

function serializeInterfaceInheritanceRelationships(EntityDetails: interfaces.EntityDetails) {
// TODO
return "[CHILD]^-[PARENT]";
function serializeInterfaceInheritanceRelationships(entityDetails: interfaces.EntityDetails) {
return entityDetails.relationships
.filter((relationship) => relationship.kind === "implementation")
.map((relationship) => `[${entityDetails.name}]^-.-[${relationship.link}],`);
}

function serializeCompositionRelationships(EntityDetails: interfaces.EntityDetails) {
// TODO
return "[CHILD]++-1>[PARENT]";
function serializeCompositionRelationships(entityDetails: interfaces.EntityDetails) {
return entityDetails.relationships
.filter((relationship) => relationship.kind === "composition")
.map((relationship) => `[${entityDetails.name}]++-1>[${relationship.link}],`);
}

function serialize(entities: interfaces.EntityDetails[]) {

// Add entitites
let dsl = entities.map((entity) => {
let entitiesDsl = entities.map((entity) => {
switch (entity.kind) {
case "class":
return serializeClass(entity);
Expand All @@ -80,9 +85,16 @@ function serialize(entities: interfaces.EntityDetails[]) {
}).reduce((a, b) => `${a}${b}`, "").split("<").join("-").split(">").join("-");

// Add relationships
dsl += entities.map(serializeInheritanceRelationships).reduce((a, b) => `${a}${b}`, "");
dsl += entities.map(serializeInterfaceInheritanceRelationships).reduce((a, b) => `${a}${b}`, "");
dsl += entities.map(serializeCompositionRelationships).reduce((a, b) => `${a}${b}`, "");
let extensionDsl = entities.map(serializeInheritanceRelationships).reduce((a, b) => `${a}${b}`, "");
let implementationDsl = entities.map(serializeInterfaceInheritanceRelationships).reduce((a, b) => `${a}${b}`, "");
let composedDsl = entities.map(serializeCompositionRelationships).reduce((a, b) => `${a}${b}`, "");

let dsl = `
${entitiesDsl}
${extensionDsl}
${implementationDsl}
${composedDsl}
`;

return `${dsl}`;
}
Expand Down
99 changes: 98 additions & 1 deletion src/provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
import * as vscode from "vscode";

const logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAM0AAABjCAYAAAA4qo" +
"T3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lm" +
"lua3NjYXBlLm9yZ5vuPBoAABCHSURBVHic7Z17vB1FfcC/N7kMbxJDhFSeeRhABN0KnhI9IFgRkQ/qSr" +
"WVE6hVW7ooFShFWyBXMGJ90iIr+ACFA1UoW6sfDC8N5PDIIS2LpkQEkiiPAIGQAAlJBm5u/5jZnM3Jnn" +
"N2dvfc3Jwz33/m7O7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TUblqzbmW1XM8T/cViGXOYjmluMixjZ2QsPUfqnqZSKznAgway11" +
"XL9b6PMG/pPUx6DdMtz1mP7LBYxjSplKZSKy1CrbinRVKca7bFMqZoO+WsT2SeR+d4v81cXS3XrbespS" +
"dJVBq9FvM5VGR5073xG3RZi6UnGazUSs/r3+OBnVELl1mCSETMzbP/32IZ6wwCkwuUt6parndjz4zFMm" +
"Yo8gzJEeCkAuVZLGOSIpXmR9VyvduexRbLNqcopflNtVz/m4JkWSxjmiKU5lHgiALkWCzbBcZbA2KMAF" +
"dUy3U7vWzpK7IozQgqEv4Z1XK9XnB7LJYxTxql2QS8hIq0shC4oFquv9DVVlksY5j/B9iXTnoP4f09AA" +
"AAAElFTkSuQmCC";

class TsUMLProvider implements vscode.TextDocumentContentProvider {

public static scheme = "tsuml";
Expand All @@ -9,9 +84,31 @@ class TsUMLProvider implements vscode.TextDocumentContentProvider {
let file = uri.query.split("file=")[1];
return `<!DOCTYPE html>
<html>
<head></head>
<head>
<style>
body {
background-color: #273746 !important;
padding: 5%;
}
.powered {
position: fixed;
bottom: 15px;
right: 25px;
color: #ffffff;
text-align: center;
}
.powered img {
width: 90px;
margin-top: -10px;
}
</style>
</head>
<body>
<img src="http://yuml.me/${file}"></div>
<div class="powered">
<p>Powered by</p>
<img src="${logo}"></img>
</div>
</body>
</html>`;
}
Expand Down

0 comments on commit 7dd6dde

Please sign in to comment.