├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ ├── release.yml │ └── run-ui-tests.yml ├── .gitignore ├── .idea └── gradle.xml ├── .run ├── Run IDE for UI Tests.run.xml ├── Run IDE with Plugin.run.xml ├── Run Plugin Tests.run.xml ├── Run Plugin Verification.run.xml └── Run Qodana.run.xml ├── CHANGELOG.md ├── README.md ├── assets └── intellij-demo.gif ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── qodana.yml ├── settings.gradle.kts └── src ├── main ├── java │ └── com │ │ └── mintlify │ │ └── document │ │ └── ui │ │ ├── DocsWindow.form │ │ ├── DocsWindow.java │ │ └── DocsWindowFactory.java ├── kotlin │ └── com │ │ └── mintlify │ │ └── document │ │ ├── MyBundle.kt │ │ ├── actions │ │ └── PopupDialogAction.kt │ │ ├── helpers │ │ └── api.kt │ │ ├── listeners │ │ └── MyProjectManagerListener.kt │ │ └── services │ │ ├── MyApplicationService.kt │ │ └── MyProjectService.kt └── resources │ ├── META-INF │ ├── plugin.xml │ └── pluginIcon.svg │ ├── icons │ └── icon.svg │ └── messages │ └── MyBundle.properties └── test ├── kotlin └── com │ └── mintlify │ └── document │ └── MyPluginTest.kt └── testData └── rename ├── foo.xml └── foo_after.xml /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Dependabot configuration: 2 | # https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates 3 | 4 | version: 2 5 | updates: 6 | # Maintain dependencies for Gradle dependencies 7 | - package-ecosystem: "gradle" 8 | directory: "/" 9 | target-branch: "next" 10 | schedule: 11 | interval: "daily" 12 | # Maintain dependencies for GitHub Actions 13 | - package-ecosystem: "github-actions" 14 | directory: "/" 15 | target-branch: "next" 16 | schedule: 17 | interval: "daily" 18 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions Workflow created for testing and preparing the plugin release in following steps: 2 | # - validate Gradle Wrapper, 3 | # - run 'test' and 'verifyPlugin' tasks, 4 | # - run Qodana inspections, 5 | # - run 'buildPlugin' task and prepare artifact for the further tests, 6 | # - run 'runPluginVerifier' task, 7 | # - create a draft release. 8 | # 9 | # Workflow is triggered on push and pull_request events. 10 | # 11 | # GitHub Actions reference: https://help.github.com/en/actions 12 | # 13 | ## JBIJPPTPL 14 | 15 | name: Build 16 | on: 17 | # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests) 18 | push: 19 | branches: [main] 20 | # Trigger the workflow on any pull request 21 | pull_request: 22 | 23 | jobs: 24 | 25 | # Run Gradle Wrapper Validation Action to verify the wrapper's checksum 26 | # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks 27 | # Build plugin and provide the artifact for the next workflow jobs 28 | build: 29 | name: Build 30 | runs-on: ubuntu-latest 31 | outputs: 32 | version: ${{ steps.properties.outputs.version }} 33 | changelog: ${{ steps.properties.outputs.changelog }} 34 | steps: 35 | 36 | # Check out current repository 37 | - name: Fetch Sources 38 | uses: actions/checkout@v2.4.0 39 | 40 | # Validate wrapper 41 | - name: Gradle Wrapper Validation 42 | uses: gradle/wrapper-validation-action@v1.0.4 43 | 44 | # Setup Java 11 environment for the next steps 45 | - name: Setup Java 46 | uses: actions/setup-java@v2 47 | with: 48 | distribution: zulu 49 | java-version: 11 50 | cache: gradle 51 | 52 | # Set environment variables 53 | - name: Export Properties 54 | id: properties 55 | shell: bash 56 | run: | 57 | PROPERTIES="$(./gradlew properties --console=plain -q)" 58 | VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" 59 | NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')" 60 | CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" 61 | CHANGELOG="${CHANGELOG//'%'/'%25'}" 62 | CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" 63 | CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" 64 | 65 | echo "::set-output name=version::$VERSION" 66 | echo "::set-output name=name::$NAME" 67 | echo "::set-output name=changelog::$CHANGELOG" 68 | echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier" 69 | 70 | ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier 71 | 72 | # Run tests 73 | - name: Run Tests 74 | run: ./gradlew test 75 | 76 | # Collect Tests Result of failed tests 77 | - name: Collect Tests Result 78 | if: ${{ failure() }} 79 | uses: actions/upload-artifact@v2 80 | with: 81 | name: tests-result 82 | path: ${{ github.workspace }}/build/reports/tests 83 | 84 | # Cache Plugin Verifier IDEs 85 | - name: Setup Plugin Verifier IDEs Cache 86 | uses: actions/cache@v2.1.7 87 | with: 88 | path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides 89 | key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} 90 | 91 | # Run Verify Plugin task and IntelliJ Plugin Verifier tool 92 | - name: Run Plugin Verification tasks 93 | run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }} 94 | 95 | # Collect Plugin Verifier Result 96 | - name: Collect Plugin Verifier Result 97 | if: ${{ always() }} 98 | uses: actions/upload-artifact@v2 99 | with: 100 | name: pluginVerifier-result 101 | path: ${{ github.workspace }}/build/reports/pluginVerifier 102 | 103 | # Run Qodana inspections 104 | - name: Qodana - Code Inspection 105 | uses: JetBrains/qodana-action@v4.2.3 106 | 107 | # Prepare plugin archive content for creating artifact 108 | - name: Prepare Plugin Artifact 109 | id: artifact 110 | shell: bash 111 | run: | 112 | cd ${{ github.workspace }}/build/distributions 113 | FILENAME=`ls *.zip` 114 | unzip "$FILENAME" -d content 115 | 116 | echo "::set-output name=filename::${FILENAME:0:-4}" 117 | 118 | # Store already-built plugin as an artifact for downloading 119 | - name: Upload artifact 120 | uses: actions/upload-artifact@v2.2.4 121 | with: 122 | name: ${{ steps.artifact.outputs.filename }} 123 | path: ./build/distributions/content/*/* 124 | 125 | # Prepare a draft release for GitHub Releases page for the manual verification 126 | # If accepted and published, release workflow would be triggered 127 | releaseDraft: 128 | name: Release Draft 129 | if: github.event_name != 'pull_request' 130 | needs: build 131 | runs-on: ubuntu-latest 132 | steps: 133 | 134 | # Check out current repository 135 | - name: Fetch Sources 136 | uses: actions/checkout@v2.4.0 137 | 138 | # Remove old release drafts by using the curl request for the available releases with draft flag 139 | - name: Remove Old Release Drafts 140 | env: 141 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 142 | run: | 143 | gh api repos/{owner}/{repo}/releases \ 144 | --jq '.[] | select(.draft == true) | .id' \ 145 | | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} 146 | 147 | # Create new release draft - which is not publicly visible and requires manual acceptance 148 | - name: Create Release Draft 149 | env: 150 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 151 | run: | 152 | gh release create v${{ needs.build.outputs.version }} \ 153 | --draft \ 154 | --title "v${{ needs.build.outputs.version }}" \ 155 | --notes "$(cat << 'EOM' 156 | ${{ needs.build.outputs.changelog }} 157 | EOM 158 | )" 159 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions Workflow created for handling the release process based on the draft release prepared 2 | # with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided. 3 | 4 | name: Release 5 | on: 6 | release: 7 | types: [prereleased, released] 8 | 9 | jobs: 10 | 11 | # Prepare and publish the plugin to the Marketplace repository 12 | release: 13 | name: Publish Plugin 14 | runs-on: ubuntu-latest 15 | steps: 16 | 17 | # Check out current repository 18 | - name: Fetch Sources 19 | uses: actions/checkout@v2.4.0 20 | with: 21 | ref: ${{ github.event.release.tag_name }} 22 | 23 | # Setup Java 11 environment for the next steps 24 | - name: Setup Java 25 | uses: actions/setup-java@v2 26 | with: 27 | distribution: zulu 28 | java-version: 11 29 | cache: gradle 30 | 31 | # Set environment variables 32 | - name: Export Properties 33 | id: properties 34 | shell: bash 35 | run: | 36 | CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d' 37 | ${{ github.event.release.body }} 38 | EOM 39 | )" 40 | 41 | CHANGELOG="${CHANGELOG//'%'/'%25'}" 42 | CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" 43 | CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" 44 | 45 | echo "::set-output name=changelog::$CHANGELOG" 46 | 47 | # Update Unreleased section with the current release note 48 | - name: Patch Changelog 49 | if: ${{ steps.properties.outputs.changelog != '' }} 50 | env: 51 | CHANGELOG: ${{ steps.properties.outputs.changelog }} 52 | run: | 53 | ./gradlew patchChangelog --release-note="$CHANGELOG" 54 | 55 | # Publish the plugin to the Marketplace 56 | - name: Publish Plugin 57 | env: 58 | PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} 59 | run: ./gradlew publishPlugin 60 | 61 | # Upload artifact as a release asset 62 | - name: Upload Release Asset 63 | env: 64 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 65 | run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/* 66 | 67 | # Create pull request 68 | - name: Create Pull Request 69 | if: ${{ steps.properties.outputs.changelog != '' }} 70 | env: 71 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 72 | run: | 73 | VERSION="${{ github.event.release.tag_name }}" 74 | BRANCH="changelog-update-$VERSION" 75 | 76 | git config user.email "action@github.com" 77 | git config user.name "GitHub Action" 78 | 79 | git checkout -b $BRANCH 80 | git commit -am "Changelog update - $VERSION" 81 | git push --set-upstream origin $BRANCH 82 | 83 | gh pr create \ 84 | --title "Changelog update - \`$VERSION\`" \ 85 | --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \ 86 | --base main \ 87 | --head $BRANCH 88 | -------------------------------------------------------------------------------- /.github/workflows/run-ui-tests.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions Workflow for launching UI tests on Linux, Windows, and Mac in the following steps: 2 | # - prepare and launch IDE with your plugin and robot-server plugin, which is needed to interact with UI 3 | # - wait for IDE to start 4 | # - run UI tests with separate Gradle task 5 | # 6 | # Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ Platform 7 | # 8 | # Workflow is triggered manually. 9 | 10 | name: Run UI Tests 11 | on: 12 | workflow_dispatch 13 | 14 | jobs: 15 | 16 | testUI: 17 | runs-on: ${{ matrix.os }} 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | include: 22 | - os: ubuntu-latest 23 | runIde: | 24 | export DISPLAY=:99.0 25 | Xvfb -ac :99 -screen 0 1920x1080x16 & 26 | gradle runIdeForUiTests & 27 | - os: windows-latest 28 | runIde: start gradlew.bat runIdeForUiTests 29 | - os: macos-latest 30 | runIde: ./gradlew runIdeForUiTests & 31 | 32 | steps: 33 | 34 | # Check out current repository 35 | - name: Fetch Sources 36 | uses: actions/checkout@v2.4.0 37 | 38 | # Setup Java 11 environment for the next steps 39 | - name: Setup Java 40 | uses: actions/setup-java@v2 41 | with: 42 | distribution: zulu 43 | java-version: 11 44 | cache: gradle 45 | 46 | # Run IDEA prepared for UI testing 47 | - name: Run IDE 48 | run: ${{ matrix.runIde }} 49 | 50 | # Wait for IDEA to be started 51 | - name: Health Check 52 | uses: jtalk/url-health-check-action@v2 53 | with: 54 | url: http://127.0.0.1:8082 55 | max-attempts: 15 56 | retry-delay: 30s 57 | 58 | # Run tests 59 | - name: Tests 60 | run: ./gradlew test 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | .qodana 4 | build 5 | bin 6 | .DS_STORE -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.run/Run IDE for UI Tests.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 15 | 17 | true 18 | true 19 | false 20 | 21 | 22 | -------------------------------------------------------------------------------- /.run/Run IDE with Plugin.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 17 | 19 | true 20 | true 21 | false 22 | 23 | 24 | -------------------------------------------------------------------------------- /.run/Run Plugin Tests.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 17 | 19 | true 20 | true 21 | false 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /.run/Run Plugin Verification.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 17 | 19 | true 20 | true 21 | false 22 | 23 | 25 | 26 | -------------------------------------------------------------------------------- /.run/Run Qodana.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 16 | 19 | 21 | true 22 | true 23 | false 24 | 25 | 26 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Mintlify Doc Writer Changelog 4 | 5 | ## [1.0.11] 6 | 7 | **Full Changelog**: https://github.com/mintlify/intellij-docs/compare/v1.0.10...v1.0.11 8 | 9 | ## [1.0.10] 10 | 11 | Add community invite and update button colours 12 | 13 | ## [1.0.9] 14 | 15 | Update description with our security policies 16 | 17 | ## [1.0.8] 18 | 19 | Update tagline 20 | 21 | ## [1.0.7] 22 | 23 | Updated the description, particularly the tagline, of the plugin 24 | 25 | ## [1.0.6] 26 | 27 | Add untilBuild for experimental build 221 28 | 29 | ## [1.0.5] 30 | 31 | Removed `untilBuild` to see if it opens compatibility 32 | 33 | ## [1.0.4] 34 | 35 | Revert back buildUntil 36 | 37 | ## [1.0.3] 38 | 39 | Patch includes 40 | 41 | - Fix bug with API only calling localhost 42 | - Fix error message with read command 43 | - Add progress.isIndeterminate = false 44 | 45 | ## [1.0.2] 46 | 47 | Address bug fix for python 48 | 49 | ## [1.0.1] 50 | 51 | Added 52 | 53 | - Support for selection without highlighting 54 | - Improved marketplace description 55 | 56 | ## [1.0.0] 57 | 58 | Update for initial marketplace publishing 59 | 60 | ## [Unreleased] 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ✍️ Mintlify Doc Writer - ⌘⇧. 2 | 3 | The official source code for the Doc Writer Intellij Plugin has been moved to the [writer](https://github.com/mintlify/writer) repo 4 | -------------------------------------------------------------------------------- /assets/intellij-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintlify/intellij-writer/e2858d98dcf17e42687b2fa11c0fe5f4cd498c80/assets/intellij-demo.gif -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.changelog.markdownToHTML 2 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 3 | 4 | fun properties(key: String) = project.findProperty(key).toString() 5 | 6 | plugins { 7 | // Java support 8 | id("java") 9 | // Kotlin support 10 | id("org.jetbrains.kotlin.jvm") version "1.6.10" 11 | // Gradle IntelliJ Plugin 12 | id("org.jetbrains.intellij") version "1.5.2" 13 | // Gradle Changelog Plugin 14 | id("org.jetbrains.changelog") version "1.3.1" 15 | // Gradle Qodana Plugin 16 | id("org.jetbrains.qodana") version "0.1.13" 17 | } 18 | 19 | group = properties("pluginGroup") 20 | version = properties("pluginVersion") 21 | 22 | // Configure project's dependencies 23 | repositories { 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | testImplementation(kotlin("test-junit")) 29 | implementation("com.github.kittinunf.fuel:fuel:2.3.1") 30 | implementation("com.github.kittinunf.fuel:fuel-gson:2.3.1") 31 | implementation("com.google.code.gson:gson:2.8.6") 32 | implementation("com.beust:klaxon:5.5") 33 | implementation(kotlin("stdlib-jdk8")) 34 | } 35 | 36 | // Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin 37 | intellij { 38 | pluginName.set(properties("pluginName")) 39 | version.set(properties("platformVersion")) 40 | type.set(properties("platformType")) 41 | 42 | // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. 43 | plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) 44 | } 45 | 46 | // Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin 47 | changelog { 48 | version.set(properties("pluginVersion")) 49 | groups.set(emptyList()) 50 | } 51 | 52 | // Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin 53 | qodana { 54 | cachePath.set(projectDir.resolve(".qodana").canonicalPath) 55 | reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath) 56 | saveReport.set(true) 57 | showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false) 58 | } 59 | 60 | tasks { 61 | // Set the JVM compatibility versions 62 | properties("javaVersion").let { 63 | withType { 64 | sourceCompatibility = it 65 | targetCompatibility = it 66 | } 67 | withType { 68 | kotlinOptions.jvmTarget = it 69 | } 70 | } 71 | 72 | wrapper { 73 | gradleVersion = properties("gradleVersion") 74 | } 75 | 76 | buildSearchableOptions { 77 | enabled = false 78 | } 79 | 80 | patchPluginXml { 81 | version.set(properties("pluginVersion")) 82 | sinceBuild.set(properties("pluginSinceBuild")) 83 | untilBuild.set(properties("pluginUntilBuild")) 84 | 85 | // Extract the section from README.md and provide for the plugin's manifest 86 | pluginDescription.set( 87 | projectDir.resolve("README.md").readText().lines().run { 88 | val start = "" 89 | val end = "" 90 | 91 | if (!containsAll(listOf(start, end))) { 92 | throw GradleException("Plugin description section not found in README.md:\n$start ... $end") 93 | } 94 | subList(indexOf(start) + 1, indexOf(end)) 95 | }.joinToString("\n").run { markdownToHTML(this) } 96 | ) 97 | 98 | // Get the latest available change notes from the changelog file 99 | changeNotes.set(provider { 100 | changelog.run { 101 | getOrNull(properties("pluginVersion")) ?: getLatest() 102 | }.toHTML() 103 | }) 104 | } 105 | 106 | // Configure UI tests plugin 107 | // Read more: https://github.com/JetBrains/intellij-ui-test-robot 108 | runIdeForUiTests { 109 | systemProperty("robot-server.port", "8082") 110 | systemProperty("ide.mac.message.dialogs.as.sheets", "false") 111 | systemProperty("jb.privacy.policy.text", "") 112 | systemProperty("jb.consents.confirmation.enabled", "false") 113 | } 114 | 115 | signPlugin { 116 | certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) 117 | privateKey.set(System.getenv("PRIVATE_KEY")) 118 | password.set(System.getenv("PRIVATE_KEY_PASSWORD")) 119 | } 120 | 121 | publishPlugin { 122 | dependsOn("patchChangelog") 123 | token.set(System.getenv("PUBLISH_TOKEN")) 124 | // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 125 | // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: 126 | // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel 127 | channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())) 128 | } 129 | } 130 | val compileKotlin: KotlinCompile by tasks 131 | compileKotlin.kotlinOptions { 132 | jvmTarget = properties("javaVersion") 133 | } 134 | val compileTestKotlin: KotlinCompile by tasks 135 | compileTestKotlin.kotlinOptions { 136 | jvmTarget = properties("javaVersion") 137 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # IntelliJ Platform Artifacts Repositories 2 | # -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html 3 | 4 | pluginGroup = com.mintlify.document 5 | pluginName = Mintlify Doc Writer 6 | # SemVer format -> https://semver.org 7 | pluginVersion = 1.1.4 8 | 9 | # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html 10 | # for insight into build numbers and IntelliJ Platform versions. 11 | pluginSinceBuild = 203 12 | pluginUntilBuild = 221.* 13 | 14 | # IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties 15 | platformType = IC 16 | platformVersion = LATEST-EAP-SNAPSHOT 17 | 18 | # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html 19 | # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 20 | platformPlugins = 21 | 22 | # Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3 23 | javaVersion = 11 24 | 25 | # Gradle Releases -> https://github.com/gradle/gradle/releases 26 | gradleVersion = 7.4 27 | 28 | # Opt-out flag for bundling Kotlin standard library. 29 | # See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details. 30 | # suppress inspection "UnusedProperty" 31 | kotlin.stdlib.default.dependency = false 32 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintlify/intellij-writer/e2858d98dcf17e42687b2fa11c0fe5f4cd498c80/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /qodana.yml: -------------------------------------------------------------------------------- 1 | # Qodana configuration: 2 | # https://www.jetbrains.com/help/qodana/qodana-yaml.html 3 | 4 | version: 1.0 5 | profile: 6 | name: qodana.recommended 7 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "Mintlify Doc Writer" 2 | -------------------------------------------------------------------------------- /src/main/java/com/mintlify/document/ui/DocsWindow.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
79 | -------------------------------------------------------------------------------- /src/main/java/com/mintlify/document/ui/DocsWindow.java: -------------------------------------------------------------------------------- 1 | package com.mintlify.document.ui; 2 | 3 | import com.intellij.openapi.actionSystem.ActionManager; 4 | import com.intellij.openapi.actionSystem.AnAction; 5 | import com.intellij.openapi.actionSystem.ex.ActionUtil; 6 | import com.intellij.openapi.actionSystem.ActionPlaces; 7 | 8 | import com.intellij.openapi.wm.ToolWindow; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.awt.event.ActionEvent; 13 | import java.awt.event.ActionListener; 14 | import java.io.IOException; 15 | import java.net.URI; 16 | import java.net.URISyntaxException; 17 | 18 | public class DocsWindow { 19 | 20 | private JPanel myToolWindowContent; 21 | private JComboBox docFormatSelector; 22 | private JButton generateDocsButton; 23 | private JButton joinCommunityLabel; 24 | private JComboBox languageSelector; 25 | 26 | public DocsWindow(ToolWindow toolWindow) { 27 | docFormatSelector.addItem("Auto-detect"); 28 | docFormatSelector.addItem("Javadoc"); 29 | docFormatSelector.addItem("Google"); 30 | docFormatSelector.addItem("JSDoc"); 31 | docFormatSelector.addItem("reST"); 32 | docFormatSelector.addItem("NumPy"); 33 | docFormatSelector.addItem("DocBlock"); 34 | docFormatSelector.addItem("Doxygen"); 35 | docFormatSelector.addItem("XML"); 36 | 37 | docFormatSelector.setEditable(false); 38 | generateDocsButton.addActionListener(new ActionListener() { 39 | @Override 40 | public void actionPerformed(ActionEvent e) { 41 | ActionManager actionManager = ActionManager.getInstance(); 42 | AnAction action = actionManager.getAction("org.intellij.sdk.action.PopupDialogAction"); 43 | ActionUtil.invokeAction(action, toolWindow.getComponent(), ActionPlaces.TOOLWINDOW_CONTENT, null, null); 44 | } 45 | }); 46 | 47 | languageSelector.addItem("English"); 48 | languageSelector.addItem("Chinese"); 49 | languageSelector.addItem("French"); 50 | languageSelector.addItem("Korean"); 51 | languageSelector.addItem("Russian"); 52 | languageSelector.addItem("Spanish"); 53 | languageSelector.addItem("Turkish"); 54 | 55 | languageSelector.setEditable(false); 56 | try { 57 | final URI joinDiscordUri = new URI("https://discord.gg/6W7GuYuxra"); 58 | joinCommunityLabel.setBorderPainted(false); 59 | joinCommunityLabel.setOpaque(false); 60 | joinCommunityLabel.addActionListener(new ActionListener() { 61 | @Override 62 | public void actionPerformed(ActionEvent e) { 63 | if (Desktop.isDesktopSupported()) { 64 | try { 65 | Desktop.getDesktop().browse(joinDiscordUri); 66 | } catch (IOException err) { /* TODO: error handling */ } 67 | } else { /* TODO: error handling */ } 68 | } 69 | }); 70 | } catch (URISyntaxException err) { 71 | /* TODO: error handling */ 72 | } 73 | } 74 | public String getSelectedDocFormat() { 75 | return (String) docFormatSelector.getSelectedItem(); 76 | } 77 | 78 | public String getSelectedLanguage() { 79 | return (String) languageSelector.getSelectedItem(); 80 | } 81 | 82 | public JPanel getContent() { 83 | return myToolWindowContent; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/mintlify/document/ui/DocsWindowFactory.java: -------------------------------------------------------------------------------- 1 | package com.mintlify.document.ui; 2 | 3 | import com.intellij.openapi.project.Project; 4 | import com.intellij.openapi.util.Key; 5 | import com.intellij.openapi.wm.ToolWindow; 6 | import com.intellij.openapi.wm.ToolWindowFactory; 7 | import com.intellij.openapi.wm.ToolWindowManager; 8 | import com.intellij.openapi.wm.ex.ToolWindowManagerEx; 9 | import com.intellij.ui.content.Content; 10 | import com.intellij.ui.content.ContentFactory; 11 | import org.jetbrains.annotations.NotNull; 12 | import org.jetbrains.annotations.Nullable; 13 | 14 | public class DocsWindowFactory implements ToolWindowFactory { 15 | public static final String ID = "Mintlify Doc Writer"; 16 | private static final Key MY_TOOL_WINDOW = Key.create("DocsWindow"); 17 | 18 | public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { 19 | DocsWindow docsWindow = new DocsWindow(toolWindow); 20 | ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); 21 | Content content = contentFactory.createContent(docsWindow.getContent(), null, false); 22 | content.putUserData(MY_TOOL_WINDOW, docsWindow); 23 | toolWindow.getContentManager().addContent(content); 24 | } 25 | 26 | @Nullable 27 | public static DocsWindow getWindow(Project project) { 28 | ToolWindowManager instance = ToolWindowManagerEx.getInstance(project); 29 | ToolWindow toolWindow = instance.getToolWindow(DocsWindowFactory.ID); 30 | if (toolWindow != null) { 31 | if (!toolWindow.isShowStripeButton()) { 32 | toolWindow.show(); 33 | } 34 | Content[] contents = toolWindow.getContentManager().getContents(); 35 | if (contents.length > 0) { 36 | Content content = contents[0]; 37 | return content.getUserData(MY_TOOL_WINDOW); 38 | } 39 | } 40 | return null; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/mintlify/document/MyBundle.kt: -------------------------------------------------------------------------------- 1 | package com.mintlify.document 2 | 3 | import com.intellij.DynamicBundle 4 | import org.jetbrains.annotations.NonNls 5 | import org.jetbrains.annotations.PropertyKey 6 | 7 | @NonNls 8 | private const val BUNDLE = "messages.MyBundle" 9 | 10 | object MyBundle : DynamicBundle(BUNDLE) { 11 | 12 | @Suppress("SpreadOperator") 13 | fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = 14 | getMessage(key, *params) 15 | 16 | @Suppress("SpreadOperator", "unused") 17 | fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = 18 | getLazyMessage(key, *params) 19 | } 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/mintlify/document/actions/PopupDialogAction.kt: -------------------------------------------------------------------------------- 1 | package com.mintlify.document.actions 2 | 3 | import com.intellij.openapi.actionSystem.AnAction 4 | import com.intellij.openapi.actionSystem.AnActionEvent 5 | import com.intellij.openapi.actionSystem.CommonDataKeys 6 | import com.intellij.openapi.command.WriteCommandAction 7 | import com.intellij.openapi.editor.Caret 8 | import com.intellij.openapi.editor.Editor 9 | import com.intellij.openapi.editor.Document 10 | import com.intellij.openapi.fileEditor.FileEditorManager 11 | import com.intellij.openapi.progress.ProgressIndicator 12 | import com.intellij.openapi.project.Project 13 | import com.intellij.openapi.progress.ProgressManager 14 | import com.intellij.openapi.progress.Task 15 | import com.intellij.notification.Notification 16 | import com.intellij.notification.Notifications 17 | import com.intellij.notification.NotificationType 18 | 19 | import com.mintlify.document.helpers.getDocFromApi 20 | import com.mintlify.document.ui.DocsWindowFactory 21 | import com.mintlify.document.helpers.Custom 22 | 23 | class PopupDialogAction : AnAction() { 24 | override fun actionPerformed(e: AnActionEvent) { 25 | 26 | val project: Project = e.getRequiredData(CommonDataKeys.PROJECT) 27 | val editor: Editor = FileEditorManager.getInstance(project).selectedTextEditor!! 28 | val document: Document = editor.document 29 | 30 | val myToolWindow = DocsWindowFactory.getWindow(project) 31 | val selectedDocFormat = myToolWindow?.selectedDocFormat ?: "Auto-detect" 32 | val selectedLanguage = myToolWindow?.selectedLanguage ?: "English" 33 | 34 | val currentCaret: Caret = editor.caretModel.currentCaret 35 | val selectedText = currentCaret.selectedText?.trim() ?: "" 36 | val selectionStart = currentCaret.selectionStart 37 | val documentText = document.text 38 | val start = documentText.indexOf(selectedText, selectionStart) 39 | // Get space before start line 40 | val startLineNumber = document.getLineNumber(start) 41 | val whitespaceBeforeLine = getWhitespaceOfLineAtOffset(document, startLineNumber) 42 | val selectedFile = FileEditorManager.getInstance(project).selectedFiles[0] 43 | val languageId = selectedFile.fileType.displayName.lowercase() 44 | 45 | val width = editor.settings.getRightMargin(project) - whitespaceBeforeLine.length 46 | val lineText = getLineText(document, startLineNumber) 47 | // Get indent size 48 | val tabSize = editor.settings.getTabSize(project) 49 | val isUseTabCharacter = editor.settings.isUseTabCharacter(project) 50 | 51 | val custom = Custom(selectedLanguage) 52 | 53 | val task = object : Task.Backgroundable(project, "Mintlify doc writer progress") { 54 | override fun run(indicator: ProgressIndicator) { 55 | indicator.text = "Generating docs" 56 | indicator.isIndeterminate = true 57 | val response = getDocFromApi( 58 | code = selectedText, 59 | languageId = languageId, 60 | fileName = selectedFile.name, 61 | context = documentText, 62 | width = width, 63 | commented = true, 64 | docStyle = selectedDocFormat, 65 | location = selectionStart, 66 | line = lineText, 67 | custom = custom 68 | ) 69 | if (response != null) { 70 | val isBelowStartLine = response.position == "belowStartLine" 71 | val insertPosition = if (isBelowStartLine) { 72 | document.getLineStartOffset(startLineNumber + 1) 73 | } else { 74 | document.getLineStartOffset(startLineNumber) + whitespaceBeforeLine.length 75 | } 76 | val insertDoc = getFormattedInsertDoc(response.docstring, whitespaceBeforeLine, isBelowStartLine, 77 | tabSize, isUseTabCharacter) 78 | 79 | WriteCommandAction.runWriteCommandAction(project) { 80 | document.insertString(insertPosition, insertDoc) 81 | } 82 | } else { 83 | val notification = Notification( 84 | "Error", 85 | "Unable to generate docs", 86 | "Please try again later or report the error to hi@mintlify.com", 87 | NotificationType.ERROR 88 | ) 89 | Notifications.Bus.notify(notification, project) 90 | } 91 | } 92 | } 93 | ProgressManager.getInstance().run(task) 94 | } 95 | } 96 | 97 | fun getWhitespaceSpaceBefore(text: String): String { 98 | val frontWhiteSpaceRemoved = text.trimStart() 99 | val firstNoneWhiteSpaceIndex = text.indexOf(frontWhiteSpaceRemoved) 100 | return text.substring(0, firstNoneWhiteSpaceIndex) 101 | } 102 | 103 | fun getLineText(document: Document, lineNumber: Int): String { 104 | val documentText = document.text 105 | val startLineStartOffset = document.getLineStartOffset(lineNumber) 106 | val startLineEndOffset = document.getLineEndOffset(lineNumber) 107 | return documentText.substring(startLineStartOffset, startLineEndOffset) 108 | } 109 | 110 | fun getWhitespaceOfLineAtOffset(document: Document, lineNumber: Int): String { 111 | val startLine = getLineText(document, lineNumber) 112 | return getWhitespaceSpaceBefore(startLine) 113 | } 114 | 115 | fun getFormattedInsertDoc(docstring: String, whitespaceBeforeLine: String, 116 | isBelowStartLine: Boolean = false, tabSize: Int, isUseTabChar: Boolean): String { 117 | var differingWhitespaceBeforeLine = whitespaceBeforeLine 118 | var lastLineWhitespace = "" 119 | // Format for tabbed position 120 | if (isBelowStartLine) { 121 | var whitespace = buildString { 122 | append("\t") 123 | } 124 | if (!isUseTabChar) { 125 | val space = " " 126 | whitespace = space.repeat(tabSize) 127 | } 128 | differingWhitespaceBeforeLine = whitespace + differingWhitespaceBeforeLine 129 | } else { 130 | lastLineWhitespace = differingWhitespaceBeforeLine 131 | } 132 | val docstringByLines = docstring.lines().mapIndexed { index, line -> ( 133 | if (index == 0 && !isBelowStartLine) { 134 | line 135 | } else { 136 | differingWhitespaceBeforeLine + line 137 | }) 138 | } 139 | return docstringByLines.joinToString("\n") + '\n' + lastLineWhitespace 140 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/mintlify/document/helpers/api.kt: -------------------------------------------------------------------------------- 1 | package com.mintlify.document.helpers 2 | 3 | import com.github.kittinunf.fuel.core.extensions.jsonBody 4 | import com.github.kittinunf.fuel.httpPost 5 | import com.github.kittinunf.fuel.httpGet 6 | import com.google.gson.Gson 7 | import com.beust.klaxon.Klaxon 8 | 9 | data class Custom( 10 | var language: String, 11 | ) 12 | 13 | data class RequestBody( 14 | var userId: String, 15 | var code: String, 16 | var languageId: String?, 17 | var fileName: String?, 18 | var context: String, 19 | var width: Int, 20 | var commented: Boolean, 21 | var email: String, 22 | var docStyle: String, 23 | var source: String, 24 | // For no-selection 25 | var location: Int, 26 | var line: String, 27 | var custom: Custom, 28 | ) 29 | 30 | data class WorkerResponse( 31 | var id: String, 32 | ) 33 | 34 | data class Response( 35 | var docstring: String, 36 | var position: String, 37 | ) 38 | 39 | data class WorkerStatusResponse( 40 | var id: String, 41 | var state: String, 42 | var reason: String? = null, 43 | var data: Response? = null, 44 | ) 45 | 46 | fun getDocFromApi( 47 | code: String, 48 | languageId: String?, 49 | fileName: String?, 50 | context: String = code, 51 | width: Int = 80, 52 | commented: Boolean = true, 53 | email: String = "", 54 | docStyle: String = "Auto-detect", 55 | location: Int, 56 | line: String, 57 | custom: Custom 58 | ): Response? { 59 | val source = "intellij" 60 | val userId = System.getProperty("user.name") 61 | val body = RequestBody(userId, code, languageId, fileName, context, width, commented, email, docStyle, source, location, line, custom) 62 | 63 | val apiBase = "https://api.mintlify.com/docs" 64 | var endpoint = "$apiBase/write/v3" 65 | if (code.isEmpty()) { 66 | endpoint += "/no-selection" 67 | } 68 | 69 | val (_, _, result) = endpoint.httpPost() 70 | .jsonBody(Gson().toJson(body).toString()) 71 | .responseString() 72 | val (payload, _) = result 73 | 74 | if (payload != null) { 75 | val id = Klaxon().parse(payload)?.id ?: return null 76 | var completedResponse: Response? = null 77 | val timeIncrement = 100 78 | var timeElapsedInMs = 0 79 | 80 | while (completedResponse == null && timeElapsedInMs < 25000) { 81 | val (_, _, resultFromWorker) = "$apiBase/worker/$id".httpGet().responseString() 82 | val (statusPayload, _) = resultFromWorker 83 | if (statusPayload != null) { 84 | val status = Klaxon().parse(statusPayload) 85 | if (status != null) { 86 | if (status.state == "completed" && status.data != null) { 87 | completedResponse = status.data 88 | } 89 | } 90 | } 91 | Thread.sleep(timeIncrement.toLong()) 92 | timeElapsedInMs += timeIncrement 93 | } 94 | 95 | return completedResponse 96 | } 97 | 98 | return null 99 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/mintlify/document/listeners/MyProjectManagerListener.kt: -------------------------------------------------------------------------------- 1 | package com.mintlify.document.listeners 2 | 3 | import com.intellij.openapi.components.service 4 | import com.intellij.openapi.project.Project 5 | import com.intellij.openapi.project.ProjectManagerListener 6 | import com.mintlify.document.services.MyProjectService 7 | 8 | internal class MyProjectManagerListener : ProjectManagerListener { 9 | 10 | override fun projectOpened(project: Project) { 11 | project.service() 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/kotlin/com/mintlify/document/services/MyApplicationService.kt: -------------------------------------------------------------------------------- 1 | package com.mintlify.document.services 2 | 3 | import com.mintlify.document.MyBundle 4 | 5 | class MyApplicationService { 6 | 7 | init { 8 | println(MyBundle.message("applicationService")) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/kotlin/com/mintlify/document/services/MyProjectService.kt: -------------------------------------------------------------------------------- 1 | package com.mintlify.document.services 2 | 3 | import com.intellij.openapi.project.Project 4 | import com.mintlify.document.MyBundle 5 | 6 | class MyProjectService(project: Project) { 7 | 8 | init { 9 | println(MyBundle.message("projectService", project.name)) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.mintlify.document 4 | Mintlify Doc Writer 5 | 1.1.4 6 | Mintlify 7 | 8 | 9 | com.intellij.modules.platform 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | The AI powered documentation writer. 38 |
39 |
40 | Writing documentation sucks. Let Mintlify take care of it. Just highlight code and see the magic. 41 |

How to generate documentation

42 | Step 1 Highlight code or place cursor on the line you want to document 43 | Step 2 Click on the Write Docs button (or hit ⌘⇧.) 44 |

Languages supported

45 |
    46 |
  • Python
  • 47 |
  • JavaScript
  • 48 |
  • TypeScript
  • 49 |
  • JSX and TSX
  • 50 |
  • PHP
  • 51 |
  • Java
  • 52 |
  • Kotlin
  • 53 |
  • More under construction...
  • 54 |
55 |

Docstring formats supported

56 |
    57 |
  • JSDoc
  • 58 |
  • reST
  • 59 |
  • NumPy
  • 60 |
  • DocBlock
  • 61 |
  • Javadoc
  • 62 |
  • Google
  • 63 |
  • More under construction...
  • 64 |
65 |
66 |
67 |

More Information

68 | Website | Twitter | Discord | GitHub 69 | Built with 💚 by the Mintlify team 70 | ]]> 71 |
72 |
73 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/icons/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/messages/MyBundle.properties: -------------------------------------------------------------------------------- 1 | name=My Plugin 2 | applicationService=Application service 3 | projectService=Project service: {0} 4 | -------------------------------------------------------------------------------- /src/test/kotlin/com/mintlify/document/MyPluginTest.kt: -------------------------------------------------------------------------------- 1 | package com.mintlify.document 2 | 3 | import com.intellij.ide.highlighter.XmlFileType 4 | import com.intellij.psi.xml.XmlFile 5 | import com.intellij.testFramework.TestDataPath 6 | import com.intellij.testFramework.fixtures.BasePlatformTestCase 7 | import com.intellij.util.PsiErrorElementUtil 8 | 9 | @TestDataPath("\$CONTENT_ROOT/src/test/testData") 10 | class MyPluginTest : BasePlatformTestCase() { 11 | 12 | fun testXMLFile() { 13 | val psiFile = myFixture.configureByText(XmlFileType.INSTANCE, "bar") 14 | val xmlFile = assertInstanceOf(psiFile, XmlFile::class.java) 15 | 16 | assertFalse(PsiErrorElementUtil.hasErrors(project, xmlFile.virtualFile)) 17 | 18 | assertNotNull(xmlFile.rootTag) 19 | 20 | xmlFile.rootTag?.let { 21 | assertEquals("foo", it.name) 22 | assertEquals("bar", it.value.text) 23 | } 24 | } 25 | 26 | override fun getTestDataPath() = "src/test/testData/rename" 27 | 28 | fun testRename() { 29 | myFixture.testRename("foo.xml", "foo_after.xml", "a2") 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/testData/rename/foo.xml: -------------------------------------------------------------------------------- 1 | 2 | 1>Foo 3 | 4 | -------------------------------------------------------------------------------- /src/test/testData/rename/foo_after.xml: -------------------------------------------------------------------------------- 1 | 2 | Foo 3 | 4 | --------------------------------------------------------------------------------