From 0b61e559fc1679e401f909ea0ca8625fc19d2a31 Mon Sep 17 00:00:00 2001 From: Gary Tierney Date: Thu, 18 Jul 2019 02:44:35 +0100 Subject: [PATCH] WIP --- .gitignore | 7 +- build.gradle | 2 - docs/api/plugin-script/on_button.md | 5 + docs/build.gradle | 28 ++- docs/docfx.json | 6 +- docs/guide/plugins/01-what-is-a-plugin.md | 9 +- docs/guide/plugins/02-creating-a-plugin.md | 10 - .../material/partials/head.tmpl.partial | 21 ++ docs/templates/material/styles/main.css | 202 ++++++++++++++++++ tools/dokka2yaml/build.gradle | 13 ++ .../dokka2yaml/YamlFileFormatDescriptor.kt | 19 ++ .../tools/dokka2yaml/YamlFileGenerator.kt | 24 +++ .../src/main/resources/dokka2yaml.properties | 2 + 13 files changed, 321 insertions(+), 27 deletions(-) create mode 100644 docs/api/plugin-script/on_button.md create mode 100644 docs/templates/material/partials/head.tmpl.partial create mode 100644 docs/templates/material/styles/main.css create mode 100644 tools/dokka2yaml/build.gradle create mode 100644 tools/dokka2yaml/src/main/kotlin/org/apollo/tools/dokka2yaml/YamlFileFormatDescriptor.kt create mode 100644 tools/dokka2yaml/src/main/kotlin/org/apollo/tools/dokka2yaml/YamlFileGenerator.kt create mode 100644 tools/dokka2yaml/src/main/resources/dokka2yaml.properties diff --git a/.gitignore b/.gitignore index 4f11942e..76d8d105 100644 --- a/.gitignore +++ b/.gitignore @@ -8,11 +8,14 @@ *~ *.class *.iml - +.project +.classpath +**/bin/ /game/data/rsa.pem /game/data/savedGames /lib/ */target/ */build/ **/build/ -**/out/ \ No newline at end of file +**/out/ +/vendor/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4da3f477..c1756fcf 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,4 @@ plugins { - id 'org.asciidoctor.gradle.asciidoctor' version '1.5.1' apply(false) - id 'org.asciidoctor.convert' version '1.5.3' apply(false) id 'org.jetbrains.kotlin.jvm' version '1.3.41' apply(false) id 'org.jetbrains.intellij' version '0.4.9' apply(false) id 'org.jmailen.kotlinter' version '1.26.0' apply(false) diff --git a/docs/api/plugin-script/on_button.md b/docs/api/plugin-script/on_button.md new file mode 100644 index 00000000..bebe6639 --- /dev/null +++ b/docs/api/plugin-script/on_button.md @@ -0,0 +1,5 @@ +--- +uid: on_button +--- + +`on_button` allows registering @"handlers" \ No newline at end of file diff --git a/docs/build.gradle b/docs/build.gradle index e1358410..afb41f98 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -1,13 +1,25 @@ -plugins { - id 'org.asciidoctor.gradle.asciidoctor' - id 'org.asciidoctor.convert' +configurations { + doclet { + transitive(true) + } } -repositories { - mavenCentral() +dependencies { + doclet files("vendor/docfx-doclet-1.0-SNAPSHOT-jar-with-dependencies.jar") } -asciidoctor { - attributes 'source-highlighter': 'prettify', - 'toc': 'left' +gradle.projectsEvaluated { + + task generateApiDocs(type: Javadoc) { + source = project(":game").sourceSets.main.java.sourceDirectories + classpath = project(":game").configurations.runtimeClasspath + project(":game").sourceSets.main.output + + options.encoding 'UTF-8' + destinationDir = file("build/generated-files") + options.addStringOption("doclet", "com.microsoft.doclet.DocFxDoclet") + options.docletpath = configurations.doclet.toList() + + dependsOn(project(":game").assemble) + } + } diff --git a/docs/docfx.json b/docs/docfx.json index f2be8312..29bb2e37 100644 --- a/docs/docfx.json +++ b/docs/docfx.json @@ -17,7 +17,7 @@ { "files": [ "api/**.yml", - "api/index.md" + "api/**.md" ] }, { @@ -50,9 +50,7 @@ "dest": "_site", "globalMetadataFiles": [], "fileMetadataFiles": [], - "template": [ - "default" - ], + "template": [ "default", "templates/material" ], "postProcessors": [], "markdownEngineName": "markdig", "noLangKeyword": false, diff --git a/docs/guide/plugins/01-what-is-a-plugin.md b/docs/guide/plugins/01-what-is-a-plugin.md index 0a0868b8..88067479 100644 --- a/docs/guide/plugins/01-what-is-a-plugin.md +++ b/docs/guide/plugins/01-what-is-a-plugin.md @@ -1 +1,8 @@ -# What is a plugin? \ No newline at end of file +# What is a plugin? + +Plugins in Apollo are a mechanism for extending the server with new functionality without having to change any of the core Java code. +Every plugin is a straight forward Kotlin project with `.plugin.kts` files containing the plugin extension behaviour and optional Kotlin source files containing generic reusable code. + +## Plugin framework architecture + +Under the hood, the Kotlin compiler transofmrs every `.plugin.kts` file into a class file that extends from @"org.apollo.game.plugin.kotlin.KotlinPluginScript", giving it access to the game @"org.apollo.game.model.World" and @"org.apollo.game.message.handler.MessageHandlerChainSet" the plugin framework is initialized with. \ No newline at end of file diff --git a/docs/guide/plugins/02-creating-a-plugin.md b/docs/guide/plugins/02-creating-a-plugin.md index ef063667..ee9fb8f2 100644 --- a/docs/guide/plugins/02-creating-a-plugin.md +++ b/docs/guide/plugins/02-creating-a-plugin.md @@ -10,17 +10,7 @@ branch prior to the release of the Kotlin plugin system for Apollo. ## Create a working environment -The project maintainers strongly recommend -[IntelliJ IDEA](https://www.jetbrains.com/idea/). -After starting IDEA, select *checkout project* with the URL: -https://github.com/apollo-rsps/apollo.git and continue. Make sure to -*import using gradle* on the next interface. - -Next, checkout the kotlin-experiments branch. To do this via IntelliJ, -use the navigation bar at the top and 'VCS > Git > Branches > -origin/kotlin-experiments > Checkout as new branch'. Name the new branch -something like kotlin-experiments-my-plugin. ## Create the plugin metadata diff --git a/docs/templates/material/partials/head.tmpl.partial b/docs/templates/material/partials/head.tmpl.partial new file mode 100644 index 00000000..eaac2fc2 --- /dev/null +++ b/docs/templates/material/partials/head.tmpl.partial @@ -0,0 +1,21 @@ +{{!Copyright (c) Oscar Vasquez. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} + + + + + {{#title}}{{title}}{{/title}}{{^title}}{{>partials/title}}{{/title}} {{#_appTitle}}| {{_appTitle}} {{/_appTitle}} + + + + {{#_description}}{{/_description}} + + + + + + + + {{#_noindex}}{{/_noindex}} + {{#_enableSearch}}{{/_enableSearch}} + {{#_enableNewTab}}{{/_enableNewTab}} + \ No newline at end of file diff --git a/docs/templates/material/styles/main.css b/docs/templates/material/styles/main.css new file mode 100644 index 00000000..c64cc7f9 --- /dev/null +++ b/docs/templates/material/styles/main.css @@ -0,0 +1,202 @@ +body { + color: #34393e; + font-family: 'Roboto', sans-serif; + line-height: 1.5; + font-size: 16px; + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; + word-wrap: break-word +} + +/* HEADINGS */ + +h1 { + font-weight: 600; + font-size: 32px; +} + +h2 { + font-weight: 600; + font-size: 24px; + line-height: 1.8; +} + +h3 { + font-weight: 600; + font-size: 20px; + line-height: 1.8; +} + +h5 { + font-size: 14px; + padding: 10px 0px; +} + +article h1, +article h2, +article h3, +article h4 { + margin-top: 35px; + margin-bottom: 15px; +} + +article h4 { + padding-bottom: 8px; + border-bottom: 2px solid #ddd; +} + +/* NAVBAR */ + +.navbar-brand>img { + color: #fff; +} + +.navbar { + border: none; + /* Both navbars use box-shadow */ + -webkit-box-shadow: 0px 1px 3px 0px rgba(100, 100, 100, 0.5); + -moz-box-shadow: 0px 1px 3px 0px rgba(100, 100, 100, 0.5); + box-shadow: 0px 1px 3px 0px rgba(100, 100, 100, 0.5); +} + +.subnav { + border-top: 1px solid #ddd; + background-color: #fff; +} + +.navbar-inverse { + background-color: #0d47a1; + z-index: 100; +} + +.navbar-inverse .navbar-nav>li>a, +.navbar-inverse .navbar-text { + color: #fff; + background-color: #0d47a1; + border-bottom: 3px solid transparent; + padding-bottom: 12px; +} + +.navbar-inverse .navbar-nav>li>a:focus, +.navbar-inverse .navbar-nav>li>a:hover { + color: #fff; + background-color: #0d47a1; + border-bottom: 3px solid white; +} + +.navbar-inverse .navbar-nav>.active>a, +.navbar-inverse .navbar-nav>.active>a:focus, +.navbar-inverse .navbar-nav>.active>a:hover { + color: #fff; + background-color: #0d47a1; + border-bottom: 3px solid white; +} + +.navbar-form .form-control { + border: none; + border-radius: 20px; +} + +/* SIDEBAR */ + +.toc .level1>li { + font-weight: 400; +} + +.toc .nav>li>a { + color: #34393e; +} + +.sidefilter { + background-color: #fff; + border-left: none; + border-right: none; +} + +.sidefilter { + background-color: #fff; + border-left: none; + border-right: none; +} + +.toc-filter { + padding: 10px; + margin: 0; +} + +.toc-filter>input { + border: 2px solid #ddd; + border-radius: 20px; +} + +.toc-filter>.filter-icon { + display: none; +} + +.sidetoc>.toc { + background-color: #fff; + overflow-x: hidden; +} + +.sidetoc { + background-color: #fff; + border: none; +} + +/* ALERTS */ + +.alert { + padding: 0px 0px 5px 0px; + color: inherit; + background-color: inherit; + border: none; + box-shadow: 0px 2px 2px 0px rgba(100, 100, 100, 0.4); +} + +.alert>p { + margin-bottom: 0; + padding: 5px 10px; +} + +.alert>ul { + margin-bottom: 0; + padding: 5px 40px; +} + +.alert>h5 { + padding: 10px 15px; + margin-top: 0; + text-transform: uppercase; + font-weight: bold; + border-radius: 4px 4px 0 0; +} + +.alert-info>h5 { + color: #1976d2; + border-bottom: 4px solid #1976d2; + background-color: #e3f2fd; +} + +.alert-warning>h5 { + color: #f57f17; + border-bottom: 4px solid #f57f17; + background-color: #fff3e0; +} + +.alert-danger>h5 { + color: #d32f2f; + border-bottom: 4px solid #d32f2f; + background-color: #ffebee; +} + +/* CODE HIGHLIGHT */ +pre { + padding: 9.5px; + margin: 0 0 10px; + font-size: 13px; + word-break: break-all; + word-wrap: break-word; + background-color: #fffaef; + border-radius: 4px; + box-shadow: 0px 1px 4px 1px rgba(100, 100, 100, 0.4); +} \ No newline at end of file diff --git a/tools/dokka2yaml/build.gradle b/tools/dokka2yaml/build.gradle new file mode 100644 index 00000000..a445102d --- /dev/null +++ b/tools/dokka2yaml/build.gradle @@ -0,0 +1,13 @@ +apply plugin: "java" +apply plugin: 'kotlin' +apply from: "$rootDir/gradle/kotlin.gradle" + +repositories { + jcenter() +} + +dependencies { + compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8' + + compile 'org.jetbrains.dokka:dokka-fatjar:0.9.18' +} \ No newline at end of file diff --git a/tools/dokka2yaml/src/main/kotlin/org/apollo/tools/dokka2yaml/YamlFileFormatDescriptor.kt b/tools/dokka2yaml/src/main/kotlin/org/apollo/tools/dokka2yaml/YamlFileFormatDescriptor.kt new file mode 100644 index 00000000..966582cd --- /dev/null +++ b/tools/dokka2yaml/src/main/kotlin/org/apollo/tools/dokka2yaml/YamlFileFormatDescriptor.kt @@ -0,0 +1,19 @@ +package org.apollo.tools.dokka2yaml + +import com.google.inject.Binder +import org.jetbrains.dokka.FormatService +import org.jetbrains.dokka.Formats.FormatDescriptor +import org.jetbrains.dokka.Formats.KotlinFormatDescriptorBase +import kotlin.reflect.KClass + +class YamlFileFormatDescriptor : KotlinFormatDescriptorBase() { + override val formatServiceClass = YamlFileGenerator::class + override fun configureAnalysis(binder: Binder) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun configureOutput(binder: Binder) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + +} \ No newline at end of file diff --git a/tools/dokka2yaml/src/main/kotlin/org/apollo/tools/dokka2yaml/YamlFileGenerator.kt b/tools/dokka2yaml/src/main/kotlin/org/apollo/tools/dokka2yaml/YamlFileGenerator.kt new file mode 100644 index 00000000..1c24ad21 --- /dev/null +++ b/tools/dokka2yaml/src/main/kotlin/org/apollo/tools/dokka2yaml/YamlFileGenerator.kt @@ -0,0 +1,24 @@ +package org.apollo.tools.dokka2yaml + +import org.jetbrains.dokka.DocumentationNode +import org.jetbrains.dokka.FormatService +import org.jetbrains.dokka.FormattedOutputBuilder +import org.jetbrains.dokka.Location + +class YamlFileGenerator(override val extension: String = ".yaml") : FormatService { + override fun createOutputBuilder(to: StringBuilder, location: Location): FormattedOutputBuilder { + return YamlFileOutputBuilder() + } +} + +class YamlFileOutputBuilder : FormattedOutputBuilder { + override fun appendNodes(nodes: Iterable) { + for (node in nodes) { + appendNode(node) + } + } + + fun appendNode(node: DocumentationNode) { + + } +} \ No newline at end of file diff --git a/tools/dokka2yaml/src/main/resources/dokka2yaml.properties b/tools/dokka2yaml/src/main/resources/dokka2yaml.properties new file mode 100644 index 00000000..798edc9f --- /dev/null +++ b/tools/dokka2yaml/src/main/resources/dokka2yaml.properties @@ -0,0 +1,2 @@ +class=org.apollo.tools.dokka2yaml.YamlFileFormatDescriptor +description=Turns KDoc and Javadoc into the code2yaml format for DocFX. \ No newline at end of file