Skip to content

Conversation

@aajtodd
Copy link
Contributor

@aajtodd aajtodd commented Jun 9, 2021

Issue #, if available:
fixes aws/aws-sdk-kotlin#153

Description of changes:
Added a new model preprocessor that sanitizes all @documentation traits and replaces all square bracket pairs with html escaped equivalents. Otherwise square brackets are treated as inline markdown in KDoc (which apparently can cause compile to fail if the link is an "invalid" identifier)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aajtodd aajtodd requested review from ianbotsf and kggilmer June 9, 2021 17:39
Comment on lines 32 to 34
// KDoc comments use inline markdown. Replace square brackets with escaped equivalents so that they
// are not rendered as invalid links
private fun sanitize(str: String): String = str.replace(Regex("(\\[)(.*)(\\])"), "[$2]")
Copy link
Contributor

Choose a reason for hiding this comment

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

Correctness: This regex won't capture nested braces or multiple braces on a line. For example:

  • a [ b [ c ] d ]a [ b [ c ] d ]
  • a [ b ] c [ d ]a [ b ] c [ d ]

This won't capture unpaired braces either, but I'm unclear if those are a problem or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unpaired braces shouldn't be a problem as far as I know since they won't be processed as inline markdown links.

@aajtodd aajtodd force-pushed the fix-generated-kdoc branch from 732dbbb to 00ac1ba Compare June 10, 2021 14:21
@aajtodd aajtodd requested a review from ianbotsf June 10, 2021 14:22
@aajtodd aajtodd merged commit 87cfa07 into main Jun 10, 2021
@aajtodd aajtodd deleted the fix-generated-kdoc branch June 10, 2021 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ses fails to build due to invalid docs

2 participants