From 92d697ed33d356cc2a0245dc0975e330c1937b75 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Fri, 4 Aug 2023 18:59:28 +0200 Subject: [PATCH] Update Developer Guides (#3088) (cherry picked from commit f7bd2ce1a5ef194643b078bd11a90fdf9b389c2b) --- ...kdocs.yml => gh-pages-deploy-dev-docs.yml} | 8 +- docs-developer/README.md | 43 +++++ {mkdocs => docs-developer}/build.gradle.kts | 2 +- .../architecture/architecture_overview.md | 123 ++++++++++++++ .../data_model/documentable_model.md | 78 ++++----- .../architecture/data_model/extra.md | 40 ++--- .../architecture/data_model/page_content.md | 144 +++++++++++++++++ .../extension_points/base_plugin.md | 33 ++++ .../extension_points/core_extension_points.md | 103 ++++++++++++ .../extension_points/extension_points.md | 87 +++++----- .../generation_implementations.md | 40 +++++ .../docs/developer_guide}/community/slack.md | 4 +- .../doc/docs/developer_guide/introduction.md | 13 +- .../plugin-development/introduction.md | 35 ++-- .../sample-plugin-tutorial.md | 4 +- .../src/doc/docs/developer_guide/workflow.md | 28 ++-- .../src/doc/docs/dokka_colors.css | 0 .../src/doc/docs/favicon.svg | 0 .../src/doc/docs/index.md | 0 {mkdocs => docs-developer}/src/doc/mkdocs.yml | 17 +- mkdocs/README.md | 33 ---- .../architecture/architecture_overview.md | 123 -------------- .../architecture/data_model/page_content.md | 140 ---------------- .../extension_points/base_extensions.md | 13 -- .../extension_points/core_extensions.md | 151 ------------------ .../docs/user_guide/output-formats/html.md | 0 settings.gradle.kts | 2 +- 27 files changed, 646 insertions(+), 618 deletions(-) rename .github/workflows/{gh-pages-deploy-mkdocs.yml => gh-pages-deploy-dev-docs.yml} (85%) create mode 100644 docs-developer/README.md rename {mkdocs => docs-developer}/build.gradle.kts (93%) create mode 100644 docs-developer/src/doc/docs/developer_guide/architecture/architecture_overview.md rename mkdocs/src/doc/docs/developer_guide/architecture/data_model/documentables.md => docs-developer/src/doc/docs/developer_guide/architecture/data_model/documentable_model.md (64%) rename {mkdocs => docs-developer}/src/doc/docs/developer_guide/architecture/data_model/extra.md (59%) create mode 100644 docs-developer/src/doc/docs/developer_guide/architecture/data_model/page_content.md create mode 100644 docs-developer/src/doc/docs/developer_guide/architecture/extension_points/base_plugin.md create mode 100644 docs-developer/src/doc/docs/developer_guide/architecture/extension_points/core_extension_points.md rename mkdocs/src/doc/docs/developer_guide/architecture/extension_points/introduction.md => docs-developer/src/doc/docs/developer_guide/architecture/extension_points/extension_points.md (63%) create mode 100644 docs-developer/src/doc/docs/developer_guide/architecture/extension_points/generation_implementations.md rename {mkdocs/src/doc/docs => docs-developer/src/doc/docs/developer_guide}/community/slack.md (50%) rename {mkdocs => docs-developer}/src/doc/docs/developer_guide/introduction.md (57%) rename {mkdocs => docs-developer}/src/doc/docs/developer_guide/plugin-development/introduction.md (62%) rename {mkdocs => docs-developer}/src/doc/docs/developer_guide/plugin-development/sample-plugin-tutorial.md (99%) rename {mkdocs => docs-developer}/src/doc/docs/developer_guide/workflow.md (83%) rename {mkdocs => docs-developer}/src/doc/docs/dokka_colors.css (100%) rename {mkdocs => docs-developer}/src/doc/docs/favicon.svg (100%) rename {mkdocs => docs-developer}/src/doc/docs/index.md (100%) rename {mkdocs => docs-developer}/src/doc/mkdocs.yml (84%) delete mode 100644 mkdocs/README.md delete mode 100644 mkdocs/src/doc/docs/developer_guide/architecture/architecture_overview.md delete mode 100644 mkdocs/src/doc/docs/developer_guide/architecture/data_model/page_content.md delete mode 100644 mkdocs/src/doc/docs/developer_guide/architecture/extension_points/base_extensions.md delete mode 100644 mkdocs/src/doc/docs/developer_guide/architecture/extension_points/core_extensions.md delete mode 100644 mkdocs/src/doc/docs/user_guide/output-formats/html.md diff --git a/.github/workflows/gh-pages-deploy-mkdocs.yml b/.github/workflows/gh-pages-deploy-dev-docs.yml similarity index 85% rename from .github/workflows/gh-pages-deploy-mkdocs.yml rename to .github/workflows/gh-pages-deploy-dev-docs.yml index b212f55b2a..9b4fdb5245 100644 --- a/.github/workflows/gh-pages-deploy-mkdocs.yml +++ b/.github/workflows/gh-pages-deploy-dev-docs.yml @@ -1,11 +1,11 @@ -name: Deploy MkDocs to GitHub Pages +name: Deploy developer docs to GitHub Pages on: push: branches: - master paths: - - 'mkdocs/**' + - 'docs-developer/**' release: types: [ published ] @@ -25,7 +25,7 @@ jobs: - uses: gradle/gradle-build-action@v2 with: gradle-home-cache-cleanup: true - - name: Get current dokka version + - name: Get current Dokka version run: echo "DOKKA_VERSION=`./gradlew :properties | grep '^version:.*' | cut -d ' ' -f 2`" >> $GITHUB_ENV working-directory: ./dokka - name: Build docs @@ -35,6 +35,6 @@ jobs: uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dokka/mkdocs/build/mkdocs + publish_dir: ./dokka/docs-developer/build/mkdocs keep_files: true full_commit_message: Publish ${{ env.DOKKA_VERSION }} documentation diff --git a/docs-developer/README.md b/docs-developer/README.md new file mode 100644 index 0000000000..d415dbf758 --- /dev/null +++ b/docs-developer/README.md @@ -0,0 +1,43 @@ +# Developer documentation + +This module contains developer documentation which is published to GitHub pages: +[kotlin.github.io/dokka](https://kotlin.github.io/dokka/). + +It is built using the [gradle-mkdocs-plugin](https://github.com/xvik/gradle-mkdocs-plugin). + +## Building + +You can build the documentation locally: + +```Bash +./gradlew :docs-developer:mkdocsBuild +``` + +The output directory is `build/mkdocs`. + +### Docker + +Alternatively, you can use Docker: + +```bash +docker run --rm -it -p 8000:8000 -v ./docs-developer/src/doc:/docs squidfunk/mkdocs-material +``` + +This will build the docs and start a web server under [localhost:8000/Kotlin/dokka](http://localhost:8000/Kotlin/dokka/). + +### Livereload server + +Alternatively, you can run a livereload server that automatically rebuilds documentation on every change: + +```Bash +./gradlew :docs-developer:mkdocsServe +``` + +By default, it is run under [localhost:3001](http://localhost:3001/), but you can change it in +[mkdocs.yml](src/doc/mkdocs.yml) by setting the `dev_addr` option. + +## Publishing + +The documentation is published automatically for all changes in master and for every GitHub release. + +See [gh-pages.yml](../.github/workflows/gh-pages-deploy-dev-docs.yml) workflow configuration for more details. diff --git a/mkdocs/build.gradle.kts b/docs-developer/build.gradle.kts similarity index 93% rename from mkdocs/build.gradle.kts rename to docs-developer/build.gradle.kts index b3c52a0ab0..e920c6f86e 100644 --- a/mkdocs/build.gradle.kts +++ b/docs-developer/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.dokkaVersionType import org.jetbrains.DokkaVersionType plugins { - id("ru.vyarus.mkdocs") version "2.3.0" + id("ru.vyarus.mkdocs") version "2.4.0" } if (dokkaVersionType != DokkaVersionType.RELEASE) { diff --git a/docs-developer/src/doc/docs/developer_guide/architecture/architecture_overview.md b/docs-developer/src/doc/docs/developer_guide/architecture/architecture_overview.md new file mode 100644 index 0000000000..d72dda91c9 --- /dev/null +++ b/docs-developer/src/doc/docs/developer_guide/architecture/architecture_overview.md @@ -0,0 +1,123 @@ +# Architecture overview + +Normally, you would think that a tool like Dokka simply parses some programming language sources and generates +HTML pages for whatever it sees along the way, with little to no abstractions. That would be the simplest and +the most straightforward way to implement an API documentation engine. + +However, it was clear that Dokka may need to generate documentation from various sources (not only Kotlin), that users +might request additional output formats (like Markdown), that users might need additional features like supporting +custom KDoc tags or rendering [mermaid.js](https://mermaid.js.org/) diagrams - all these things would require changing +a lot of code inside Dokka itself if all solutions were hardcoded. + +For this reason, Dokka was built from the ground up to be easily extensible and customizable by adding several layers +of abstractions to the data model, and by providing pluggable extension points, giving you the ability to introduce +selective changes on a given level. + +## Overview of data model + +Generating API documentation begins with input source files (`.kt`, `.java`, etc) and ends with some output files +(`.html`/`.md`, etc). However, to allow for extensibility and customization, several input and output independent +abstractions have been added to the data model. + +Below you can find the general pipeline of processing data gathered from sources and the explanation for each stage. + +```mermaid +flowchart TD + Input --> Documentables --> Pages --> Output +``` + +* `Input` - generalization of sources, by default Kotlin / Java sources, but could be virtually anything +* [`Documentables`](data_model/documentable_model.md) - unified data model that represents _any_ parsed sources as a + tree, independent of the source language. Examples of a `Documentable`: class, function, package, property, etc +* [`Pages`](data_model/page_content.md) - universal model that represents output pages (e.g a function/property page) + and the content it's composed of (lists, text, code blocks) that the users needs to see. Not to be confused with + `.html` pages. Goes hand in hand with the so-called [Content model](data_model/page_content.md#content-model). +* `Output` - specific output formats like HTML / Markdown / Javadoc and so on. This is a mapping of the pages/content + model to a human-readable and visual representation. For instance: + * `PageNode` is mapped as + * `.html` file for the HTML format + * `.md` file for the Markdown format + * `ContentList` is mapped as + * `
  • ` / `