rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Strip leading \brief or \short at the start of Doxygen comment

Open HadrienG2 opened this issue 1 year ago • 0 comments

rustdoc treats the first paragraph of an item's description as a brief description to be used in higher level docs (module item list, etc). Historically, Doxygen has required use of \brief or \short to achieve the same effect. Nowadays you can use JAVADOC_AUTOBRIEF instead, but many older C/++ projects will still use the \brief or \short Doxygen directive style.

As a result, the autogenerated rustdoc ends up being spammed with leading \briefs:

image

It would be great if bindgen could detect \briefs at the start of Doxygen comments and strip them off instead.

Input C/C++ Header

/** \brief Object info attribute (name and value strings)
 *
 * \sa hwlocality_info_attr
 */
struct hwloc_info_s {};

Bindgen Invocation

$ bindgen input.h

Actual Results

Bindgen keeps the leading \brief in the rustdoc output, resulting in the rustdoc \brief spam illustrated above.

#[doc = " \\brief Object info attribute (name and value strings)\n\n \\sa hwlocality_info_attr"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct hwloc_info_s {}

Expected Results

Bindgen strips the leading \brief to switch to rustdoc's brief description convention.

#[doc = "Object info attribute (name and value strings)\n\n \\sa hwlocality_info_attr"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct hwloc_info_s {}

HadrienG2 avatar Feb 12 '24 07:02 HadrienG2