Skip to content

Commit

Permalink
Add substitute for method names
Browse files Browse the repository at this point in the history
  • Loading branch information
dj2 committed Sep 10, 2022
1 parent 980c29d commit e34d5ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
27 changes: 20 additions & 7 deletions scripts/api_doc_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,30 @@ def substitute(lang, str)
str.gsub(/%%(.*?)%%/) do |m|
cmd = $1.strip!

if lang == "cpp"
if cmd == 'null'
"nullptr"
if cmd =~ /method\(([^,]*),\s+([^\)]*)\)/
obj = $1
method = $2

display_name = if lang == "cpp"
"#{obj.CamelCase}::#{method.CamelCase}"
else
gen_cpp_type_link(cmd)
"wgpu#{obj.CamelCase}#{method.CamelCase}"
end

"[#{display_name}](##{gen_anchor(obj)}-#{method.CamelCase})"
else
if cmd == 'null'
"NULL"
if lang == "cpp"
if cmd == 'null'
"nullptr"
else
gen_cpp_type_link(cmd)
end
else
gen_c_type_link(cmd)
if cmd == 'null'
"NULL"
else
gen_c_type_link(cmd)
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ enum:
Factor is set to one minus the destionation alpha value. <br>
`(1 - A_dst, 1 - A_dst, 1 - A_dst, 1 - A_dst)`
constant: >
Factor is set to the constant value.
Factor is set to the constant value.<br>
(See %% method(render pass encoder, set blend constant) %%
for setting of the constant value.)<br>
`(R_const, G_const, B_const, A_const)`
one minus constant: >
Factor is set to one minus the constant value.
Factor is set to one minus the constant value.<br>
(See %% method(render pass encoder, set blend constant) %%
for setting of the constant value.)<br>
`(1 - R_const, 1 - G_const, 1 - B_const, 1 - A_const)`
Expand Down

0 comments on commit e34d5ff

Please sign in to comment.