Unverified Commit 16258f21 authored by Viktor Söderqvist's avatar Viktor Söderqvist Committed by GitHub
Browse files

More modules API ref formatting fixes (#8344)

Fix broken formatting in `RM_Call` and `RM_CreateDataType`,
`RM_SubscribeToServerEvent` (nested lists, etc. in list items).

Unhide docs of `RM_LoadDataTypeFromString` and
`RM_SaveDataTypeToString` by removing blank line between docs and
function.

Clarification added to `RM__Assert`: Recommentation to use the
`RedisModule_Assert` macro instead.

All names containing underscores (variable and macro names) are
wrapped in backticks (if not already wrapped in backticks). This
prevents underscore from being interpreted as italics in some
cases.

Names including a wildcard star, e.g. RM_Defrag*(), is wrapped in
backticks (and RM replaced by RedisModule in this case). This
prevents the * from being interpreted as an italics marker.

A list item with a sublist, a paragraph and another sublist is a
combination which seems impossible to achieve with RedCarped
markdown, so the one occurrence of this is rewritten.

Various trivial changes (typos, backticks, etc.).

Ruby script:

* Replace `RM_Xyz` with `RedisModule_Xyz` in docs. (RM is correct
  when refering to the C code but RedisModule is correct in the
  API docs.)
* Automatic backquotes around C functions like `malloc()`.
* Turn URLs into links. The link text is the URL itself.
* Don't add backticks inside bold (**...**)
parent 6401920d
This diff is collapsed.
...@@ -9,13 +9,21 @@ def markdown(s) ...@@ -9,13 +9,21 @@ def markdown(s)
s.chop! while s[-1] == "\n" || s[-1] == " " s.chop! while s[-1] == "\n" || s[-1] == " "
lines = s.split("\n") lines = s.split("\n")
newlines = [] newlines = []
# Backquote function, macro and type names, except if already backquoted and # Fix some markdown, except in code blocks indented by 4 spaces.
# in code blocks indented by 4 spaces.
lines.each{|l| lines.each{|l|
if not l.start_with?(' ') if not l.start_with?(' ')
l = l.gsub(/(?<!`)RM_[A-z()]+/){|x| "`#{x}`"} # Rewrite RM_Xyz() to `RedisModule_Xyz()`. The () suffix is
l = l.gsub(/(?<!`)RedisModule[A-z()]+/){|x| "`#{x}`"} # optional. Even RM_Xyz*() with * as wildcard is handled.
l = l.gsub(/(?<!`)REDISMODULE_[A-z]+/){|x| "`#{x}`"} l = l.gsub(/(?<!`)RM_([A-z]+(?:\*?\(\))?)/, '`RedisModule_\1`')
# Add backquotes around RedisModule functions and type where missing.
l = l.gsub(/(?<!`)RedisModule[A-z]+(?:\*?\(\))?/){|x| "`#{x}`"}
# Add backquotes around c functions like malloc() where missing.
l = l.gsub(/(?<![`A-z])[a-z_]+\(\)/, '`\0`')
# Add backquotes around macro and var names containing underscores.
l = l.gsub(/(?<![`A-z\*])[A-Za-z]+_[A-Za-z0-9_]+/){|x| "`#{x}`"}
# Link URLs preceded by space (i.e. when not already linked)
l = l.gsub(/ (https?:\/\/[A-Za-z0-9_\/\.\-]+[A-Za-z0-9\/])/,
' [\1](\1)')
end end
newlines << l newlines << l
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment