Escape backticks in a docstring by doubling them up. This is a little tricky because RST requires a non-letter character after the closing backticks, but some CDPs docs have things like "`AxNodeId`s". If we double the backticks in that string, then it won't be valid RST. The fix is
(docstr)
| 97 | |
| 98 | |
| 99 | def escape_backticks(docstr): |
| 100 | """Escape backticks in a docstring by doubling them up. |
| 101 | |
| 102 | This is a little tricky because RST requires a non-letter character after |
| 103 | the closing backticks, but some CDPs docs have things like "`AxNodeId`s". |
| 104 | If we double the backticks in that string, then it won't be valid RST. The |
| 105 | fix is to insert an apostrophe if an "s" trails the backticks. |
| 106 | """ |
| 107 | |
| 108 | def replace_one(match): |
| 109 | if match.group(2) == "s": |
| 110 | return f"``{match.group(1)}``'s" |
| 111 | if match.group(2): |
| 112 | # This case (some trailer other than "s") doesn't currently exist |
| 113 | # in the CDP definitions, but it's here just to be safe. |
| 114 | return f"``{match.group(1)}`` {match.group(2)}" |
| 115 | return f"``{match.group(1)}``" |
| 116 | |
| 117 | # Sometimes pipes are used where backticks should have been used. |
| 118 | docstr = docstr.replace("|", "`") |
| 119 | return BACKTICK_RE.sub(replace_one, docstr) |
| 120 | |
| 121 | |
| 122 | def inline_doc(description): |
no outgoing calls
no test coverage detected