Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d9981708
Commit
d9981708
authored
Apr 20, 2016
by
antirez
Browse files
Simple Ruby script to generate reference doc added.
parent
0fd6d548
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/modules/gendoc.rb
0 → 100644
View file @
d9981708
# gendoc.rb -- Converts the top-comments inside module.c to modules API
# reference documentaiton in markdown format.
# Convert the C comment to markdown
def
markdown
(
s
)
s
=
s
.
gsub
(
/\*\/$/
,
""
)
s
=
s
.
gsub
(
/^ \* {0,1}/
,
""
)
s
=
s
.
gsub
(
/^\/\* /
,
""
)
s
.
chop!
while
s
[
-
1
]
==
"
\n
"
||
s
[
-
1
]
==
" "
return
s
end
# Given the source code array and the index at which an exported symbol was
# detected, extracts and outputs the documentation.
def
docufy
(
src
,
i
)
m
=
/RM_[A-z0-9]+/
.
match
(
src
[
i
])
proto
=
src
[
i
].
sub
(
"{"
,
""
).
strip
+
";
\n
"
puts
"##
#{
m
[
0
]
}
\n\n
"
puts
"
#{
proto
}
\n
"
comment
=
""
while
true
i
=
i
-
1
comment
=
src
[
i
]
+
comment
break
if
src
[
i
]
=~
/\/\*/
end
comment
=
markdown
(
comment
)
puts
comment
+
"
\n\n
"
end
puts
"# Modules API reference
\n\n
"
src
=
File
.
open
(
"../module.c"
).
to_a
src
.
each_with_index
{
|
line
,
i
|
if
line
=~
/RM_/
&&
line
[
0
]
!=
' '
&&
line
[
0
]
!=
'#'
&&
line
[
0
]
!=
'/'
if
src
[
i
-
1
]
=~
/\*\//
docufy
(
src
,
i
)
end
end
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment