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

Remove extra backslashes from code snippets #3139

Merged
merged 3 commits into from
Nov 5, 2024
Merged

Conversation

mullermp
Copy link
Contributor

@mullermp mullermp commented Nov 2, 2024

Closes #3132

We were addressing Yard warnings by escaping backslashes, but this also applied to code snippets. I tried a solution where we only escaped when not in a code section but this approach failed. This is because we have a multi-tier doc system with html -> markdown (rdiscount) -> yard, each handling escaping differently. This approach fixes the docs visibly but we will have warning outputs when curly braces are used outside of code blocks. This doesn't happen often, a majority of docs use code blocks.

@mullermp
Copy link
Contributor Author

mullermp commented Nov 2, 2024

See generated changes

@@ -11,8 +11,6 @@ module AsymmetricCredentials

N_MINUS_2 = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551 - 2

# @param [String] :access_key_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove these? They are still the correct paramters here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The module is API private and these were wrong. These are positional parameters but they were symbolized name, so it produced a warning. I just deleted them because it's clear what they are (and API private).

nil
end
end

def generated_examples(operation, api)
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this just not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so...

@@ -118,10 +118,6 @@ def html_to_markdown(html, options = {})
if html
html = "<p>#{html}</p>" unless html.match(/<\w+>/)

# unescaped curly braces cause YARD errors, they are interpreted
# as code links.
html = html.gsub('{', "\\{").gsub('}', "\\}")
Copy link
Contributor

Choose a reason for hiding this comment

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

could we take an escape_curly_braces option and pass it only when this is called for code docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That doesn't fix inline code snippets in the documentation. This applies on the whole block of documentation text.

@mullermp mullermp merged commit e3b9478 into version-3 Nov 5, 2024
30 checks passed
@mullermp mullermp deleted the fix-doc-syntax branch November 5, 2024 22:13
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.

2 participants