Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KDoc fixes for IntelliJ 2024.X #613

Merged
merged 15 commits into from
Apr 16, 2024
Merged

KDoc fixes for IntelliJ 2024.X #613

merged 15 commits into from
Apr 16, 2024

Conversation

Jolanrensen
Copy link
Collaborator

@Jolanrensen Jolanrensen commented Mar 4, 2024

Attempting to fix #585 and some of #605

Cannot fully fix until JetBrains/markdown#150 is merged and inside IntelliJ

This fixes:

  • Making sure all spaces in code examples are inside ` ` brackets. Otherwise, the background will not render.
  • If a ` code block ` (like that) starts and ends with a space, one surrounding space will be removed. So add one extra like ` this `.
  • Making sure that code periods in grammars, like ., are actually code and bold.
  • `block`\n`block` is rendered like `block` `block`, but that again introduces a space that shouldn't be there, so fixing those.
  • With the doc processor, putting all spaces inside code spans increases the change of getting something like``this. This can however be avoided by using codetags in intellij as those tags are removed anyways. Might be converted to span if they are ever rendered correctly.
  • Same with **, alternating with __
  • code in references should have ` tags (Only fixed in grammars for now, as it's invisible in IDE anyways)

@Jolanrensen Jolanrensen added the KDocs Improvements or additions to KDocs label Mar 4, 2024
@Jolanrensen Jolanrensen added this to the 0.13.0 milestone Mar 4, 2024
@Jolanrensen Jolanrensen marked this pull request as ready for review March 27, 2024 15:25
@Jolanrensen Jolanrensen changed the title WIP: KDoc fixes for IntelliJ 2024.X KDoc fixes for IntelliJ 2024.X Mar 27, 2024
@Jolanrensen
Copy link
Collaborator Author

@zaleslaw @koperagen It's ready I think. Although, it might be hard to review.
I mainly applied the rules I specified in the top-comment.
As described in the issue: #585, the latest nightly of the IDE fixed some part of the rendering and the docs looks best at that version (well, actually they look better in the 2023 version, but that's not what the PR is about). There are still some space-trim discrepancies in intellij, but I just followed the GFM spec in those cases, so they should look good in the future.

@zaleslaw
Copy link
Collaborator

@Jolanrensen what is the best way to test this? I suppose, looking at the rendering docs, isn't it?

@Jolanrensen
Copy link
Collaborator Author

Jolanrensen commented Mar 28, 2024

@Jolanrensen what is the best way to test this? I suppose, looking at the rendering docs, isn't it?

Yep, and the best way to view those is by letting IntelliJ render them. That works best when the project is published to mavenLocal and you're viewing the source from another project. (Because the generated-sources dir isn't attached as "sources" by intellij, so the highlighting breaks)

Actually, it might be awesome if we could see the rendered docs for an entire file while working on it, like the "render all doc comments" button here:
image
(that button doesn't work with the intellij plugin for the doc preprocessor atm)

public interface PlainDslName

/** .[**frameCol**][ColumnsSelectionDsl.frameCol] */
/** __`.`__[**`frameCol`**][ColumnsSelectionDsl.frameCol] */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How this works? What kind of formatting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__ is the same as ** :) so in this case it makes the period bold+code style.
I switched to using __ instead of ** here because:

  • kdocs don't like * at the start. It doesn't always recognize the difference between * indicating the KDoc or * for making stuff bold
  • If this piece of text is copied over next to something else bold, like **`singleColumn`**{@include [ColumnGroupName]}, the result would become **`singleColumn`****`.`**[**`frameCol`**]... and break markdown because of the ****.
    Like this:
    singleColumn****.frameCol...
    With dashes, instead it becomes **`singleColumn`**__`.`__[**`frameCol`**]... which renders correctly:
    singleColumn.frameCol...

@@ -270,6 +277,7 @@ public fun <T, C> Update<T, C>.with(expression: UpdateExpression<T, C, C?>): Dat
}

/** [Update with][Update.with] to provide a new value for every selected cell giving its row. */
@ExcludeFromSources
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's happened when we exclude this from source? Or all documentation interfaces should be shipped with this annotation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed. We should annotate all our documentation interfaces with @ExcludeFromSources. This will exclude them from the sources+compilation and thus shrink the bytecode (in theory). For this PR I started gradually introducing them on a few interfaces already, but far from all of them (#605). There's no rush though, so we can just annotate them whenever we like.

@@ -53,7 +53,8 @@ internal interface SelectingColumns {
*/
interface OperationArg

/** {@set [OperationArg] operation} */
// Using <code>` notation to not create double `` when including
/** {@set [OperationArg] <code>`operation`</code>} */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a table with all our special tricks:))

Copy link
Collaborator

@zaleslaw zaleslaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just left a couple of comments to be familiar with some syntax

@Jolanrensen
Copy link
Collaborator Author

I bumped the docPreprocessor version to 0.3.5 for the project.
You can now view the docs easier in the update IntelliJ plugin, found at the release: https://github.com/Jolanrensen/docProcessorGradlePlugin/releases/tag/v0.3.5

@Jolanrensen Jolanrensen merged commit 8990376 into master Apr 16, 2024
4 checks passed
@Jolanrensen Jolanrensen deleted the kdoc-fixes branch April 16, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KDocs Improvements or additions to KDocs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KDoc rendering looks odd on 2024 Nightly IntelliJ
2 participants