Skip to content

Commit

Permalink
Added launcher file + several enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Nov 23, 2017
1 parent 0bacee0 commit 38a4c9f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 43 deletions.
15 changes: 15 additions & 0 deletions org.uqbar.project.wollok.launch/Generate WollokDoc.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.uqbar.project.wollok.launch/xtend-gen/org/uqbar/project/wollok/wollokDoc/WollokDocParser.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.uqbar.project.wollok.wollokDoc.WollokDocParser"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="&quot;/home/fernando/workspace/wollok-dev/wollok/org.uqbar.project.wollok.lib/src/wollok/&quot; -folder &quot;/home/fernando/workspace/wollok-doc/wollok-site/wollokDoc&quot;"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.uqbar.project.wollok.launch"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import static extension org.uqbar.project.wollok.model.WollokModelExtensions.*
*/
class WollokDocParser extends WollokChecker {

val static HEADER_ON = "<h2>"
val static HEADER_OFF = "</h2>"
val static HEADER2_ON = "<h3>"
val static HEADER2_OFF = "</h3>"
val static HEADER3_ON = "<h4>"
Expand Down Expand Up @@ -92,14 +90,13 @@ class WollokDocParser extends WollokChecker {
<link rel="stylesheet" href="./mdb/css/bootstrap.min.css">
<link rel="stylesheet" href="./mdb/css/mdb.min.css">
<link rel="stylesheet" href="./mdb/css/style.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="./js/navbar.js"></script>
</head>
<body>
<hr>
<div class="container">
«generateNavbar»
<div id="content"/>
<div id="content" class="container" style="padding-top: 5rem;"/>
</div>
</body>
</html>
Expand All @@ -113,18 +110,13 @@ class WollokDocParser extends WollokChecker {
file => [
allFiles.add(mainFile)
val htmlFile = mainFile.name.toHtmlFile
wollokDocFile = Files.newWriter(new File(outputFolder + File.separator + htmlFile), Charsets.UTF_8) => [
write('''
<hr>
wollokDocFile = Files.newWriter(new File(outputFolder + File.separator + htmlFile), Charsets.UTF_8)
wollokDocFile
.write('''
<div class="container">
<p class="mx-auto">«lastUpdated»</p>
<hr>
''')
]
elements.forEach [ generateWollokDoc ]
wollokDocFile.write('''
<p>«lastUpdated»</p>
«elements.forEach [ generateWollokDoc ]»
</div>
<p>«lastUpdated»</p>
''')
]
wollokDocFile.close
Expand All @@ -134,21 +126,30 @@ class WollokDocParser extends WollokChecker {
fileName.replace(WollokConstants.CLASS_OBJECTS_EXTENSION, "html")
}

def String libraryName(String fileName) {
fileName.split("\\.").head
}

def String generateNavbar() {
'''
<nav class="navbar navbar-expand-lg navbar-dark red darken-2">
<a class="navbar-brand" href="#">
<img src="../images/WollokLogo.png" height="50" alt="">
</a>
<ul class="navbar-nav mr-auto">
«allFiles.map [ file | file.generateLink ].join(" ")»
</ul>
<nav class="navbar navbar-expand-lg navbar-dark red darken-2 fixed-top">
<div class="container"/>
<a class="navbar-brand" href="#">
<img src="../images/WollokLogo.png" height="50" alt="">
</a>
<ul class="navbar-nav mr-auto">
«allFiles.map [ file | file.generateLink ].join(" ")»
</ul>
<span class="navbar-text white-text">
Complete Language Reference
</span>
</div>
</nav>
'''
}

def String generateLink(File file) {
val libraryName = file.name.split("\\.").head
val libraryName = file.name.libraryName
'''
<li class="nav-item" id="«libraryName»">
<a class="nav-link" href="javascript:selectFile('«libraryName»')">«file.name» <span class="sr-only">(current)</span></a>
Expand All @@ -162,23 +163,25 @@ class WollokDocParser extends WollokChecker {
def dispatch void generateWollokDoc(WConstructor c) {
writeFile(BOLD_ON + WollokConstants.CONSTRUCTOR + BOLD_OFF + "(" + c.parameters.map[name].join(", ") + ")")
c.showComment
writeFile(HORIZONTAL_LINE)
}

def dispatch void generateWollokDoc(WMethodDeclaration m) {
val comment = m.comment
val abstractDescription = if (m.abstract) ITALIC_ON + "abstract" + ITALIC_OFF + SPACE else ""
val nativeDescription = if (m.native) ITALIC_ON + "native" + ITALIC_OFF + SPACE else ""
writeFile(TABLE_DATA_ON + BOLD_ON + m.name + BOLD_OFF + m.parametersAsString + TABLE_DATA_OFF +
TABLE_DATA_ON + nativeDescription +
comment + TABLE_DATA_OFF)
val abstractDescription = if (m.abstract) badge("abstract", "light-blue") + SPACE else ""
val nativeDescription = if (m.native) badge("native", "indigo") else ""
writeFile(TABLE_DATA_ON + BOLD_ON + m.name + BOLD_OFF + m.parametersAsString + SPACE + SPACE +
abstractDescription + SPACE + SPACE + nativeDescription + SPACE + TABLE_DATA_OFF +
TABLE_DATA_ON + comment + TABLE_DATA_OFF)
}

def dispatch getDefinedConstructors(WMethodContainer mc) { newArrayList }
def dispatch getDefinedConstructors(WClass c) { c.constructors }

def dispatch void generateWollokDoc(WMethodContainer mc) {
header(mc.imageName + SPACE + mc.name, mc.name)
writeFile(showHierarchy(mc.parent))
writeFile(showHierarchy(mc))
mc.showComment
val constructors = mc.members.filter(WConstructor)
val constructors = mc.definedConstructors
if (!constructors.isEmpty) {
header2("Constructors")
writeFile(TABLE_ON)
Expand All @@ -191,7 +194,7 @@ class WollokDocParser extends WollokChecker {
writeFile(TABLE_ON)
tableHeader("Method", "Description")
writeFile(TABLE_BODY_ON)
mc.methods.forEach [
mc.methods.sortBy [ name ].forEach [
writeFile(TABLE_ROW_ON)
generateWollokDoc
writeFile(TABLE_ROW_OFF)
Expand All @@ -203,19 +206,28 @@ class WollokDocParser extends WollokChecker {
writeFile(HORIZONTAL_LINE)
}

def String showHierarchy(WClass c) {
if (c === null) return ""
'''
def String showHierarchy(WMethodContainer c) {
if (!c.hasRealParent) {
return ""
}
val parent = c.parent
return '''
<ul>
<li>inherits from «linkTo(c.name, c.file.URI.lastSegment)»</li>
«showHierarchy(c.parent)»
<li>inherits from «linkTo(parent.name, parent.file.URI.lastSegment)»</li>
«showHierarchy(parent)»
</ul>
'''
}

def String linkTo(String name, String fileName) {
'''
<a href="«fileName.toHtmlFile»#«name»">«name»</a>
<a href="javascript:selectFile('«fileName.libraryName»', '«name»')">«name»</a>
'''
}

def badge(String title, String color) {
'''
<span class="badge badge-pill «color»">«title»</span><br>
'''
}

Expand All @@ -226,11 +238,12 @@ class WollokDocParser extends WollokChecker {
}

def void writeInheritedMethods(WMethodContainer mc) {
val currentMc = mc.parent
if (mc.parent === null) {
if (!mc.hasRealParent) {
return
}
val inheritedMethods = currentMc.methods.map [ messageName ].join(", ")
val currentMc = mc.parent
val methodsOverriden = mc.methods.filter [ overrides ].map [ name ].toList
val inheritedMethods = currentMc.methods.filter [ !methodsOverriden.contains(it.name) ].map [ messageName ].sort.join(", ")
card("Methods inherited from " + currentMc.name, inheritedMethods)
writeInheritedMethods(currentMc)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,10 @@ class WMethodContainerExtensions extends WollokModelExtensions {
def static dispatch boolean callsSuper(EObject it) { eAllContents.exists[ e | e.callsSuper] }

def static dispatch boolean hasRealParent(EObject it) { false }
def static dispatch boolean hasRealParent(WNamedObject wko) { wko.parent !== null && wko.parent.name !== null && !wko.parent.name.equals(WollokConstants.ROOT_CLASS) }
def static dispatch boolean hasRealParent(WClass c) { c.parent !== null && c.parent.name !== null && !c.parent.name.equals(WollokConstants.ROOT_CLASS) }
def static dispatch boolean hasRealParent(WNamedObject wko) { wko.parent !== null && wko.parent.name !== null && !wko.parent.fqn.equalsIgnoreCase(WollokConstants.FQN_ROOT_CLASS) }
def static dispatch boolean hasRealParent(WClass c) {
c.parent !== null && c.parent?.name !== null && !c.parent?.fqn?.equalsIgnoreCase(WollokConstants.FQN_ROOT_CLASS)
}

/* Including file name for multiple tests */
def static getFullName(WTest test, boolean processingManyFiles) {
Expand Down

0 comments on commit 38a4c9f

Please sign in to comment.