Hi @ioquatix,
Thank you for writing these bindings! 👍
I'm trying to extract function comments.
However, whenever there are angle brackets in a comment, extra newline \n characters are being added.
The comments are distorted with those extra newline characters.
Here's an example:
test-header.h
#pragma once
/**
* This is the description of the `test_function`.
* Following option strings are supported:
* -a,--arg1 <VALUE>
* -b,--arg2 <VALUE>
*/
void test_function(const char* option);
ffi-clang-test.rb
require 'ffi/clang'
idx = FFI::Clang::Index.new
tu = idx.parse_translation_unit("test-header.h")
cr = tu.cursor
cr.visit_children do |cursor, parent|
next :continue if cursor.comment.kind == :comment_null
puts
puts ">> cursor.comment.child.text:"
puts "#{cursor.comment.child.text}"
puts
puts ">> cursor.comment.child.text.dump:"
puts "#{cursor.comment.child.text.dump}"
puts
puts ">> cursor.raw_comment_text:"
puts "#{cursor.raw_comment_text}"
next :recurse
end
After running the script, here's the output:
$ ruby ffi-clang-test.rb
>> cursor.comment.child.text:
This is the description of the `test_function`.
Following option strings are supported:
-a,--arg1
<VALUE
>
-b,--arg2
<VALUE
>
>> cursor.comment.child.text.dump:
" This is the description of the `test_function`.\n Following option strings are supported:\n -a,--arg1 \n<VALUE\n>\n -b,--arg2 \n<VALUE\n>"
>> cursor.raw_comment_text:
/**
* This is the description of the `test_function`.
* Following option strings are supported:
* -a,--arg1 <VALUE>
* -b,--arg2 <VALUE>
*/
You can observe that there are extra newline characters \n added in the output of cursor.comment.child.text causing the broken output.
Could you please look into it?
Thank you!
PFA the sample header and Ruby script in compressed format:
Hi @ioquatix,
Thank you for writing these bindings! 👍
I'm trying to extract function comments.
However, whenever there are angle brackets in a comment, extra newline
\ncharacters are being added.The comments are distorted with those extra newline characters.
Here's an example:
test-header.h
ffi-clang-test.rb
After running the script, here's the output:
You can observe that there are extra newline characters
\nadded in the output ofcursor.comment.child.textcausing the broken output.Could you please look into it?
Thank you!
PFA the sample header and Ruby script in compressed format: