Skip to content

Commit

Permalink
Do not auto-generate doc for a tag that has hand-written one.
Browse files Browse the repository at this point in the history
  • Loading branch information
kamadak committed Sep 7, 2022
1 parent ab77d18 commit 3f5bb96
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,25 @@ macro_rules! unit_expand {
unit_expand!($($built,)* UnitPiece::Tag(Tag::$tag) ; $($rest)*) );
}

// This requires Rust 1.54 or later.
// macro_rules! use_desc_if_attr_is_empty {
// ( $desc:expr, $(#[$attr:meta])+ ) => ( "" );
// ( $desc:expr, ) => ( $desc );
// }

macro_rules! define_tag_const_with_doc {
( $name:ident, $ctx:path, $num:expr, $desc:expr, $(#[$attr:meta])+ ) => (
$( #[$attr] )*
#[allow(non_upper_case_globals)]
pub const $name: Tag = Tag($ctx, $num);
);
( $name:ident, $ctx:path, $num:expr, $desc:expr, ) => (
#[doc = $desc]
#[allow(non_upper_case_globals)]
pub const $name: Tag = Tag($ctx, $num);
);
}

macro_rules! generate_well_known_tag_constants {
(
$( |$ctx:path| $(
Expand All @@ -174,10 +193,12 @@ macro_rules! generate_well_known_tag_constants {
// // <https://github.com/rust-lang/rust/issues/25207>.
impl Tag {
$($(
$( #[$attr] )*
#[doc = $desc]
#[allow(non_upper_case_globals)]
pub const $name: Tag = Tag($ctx, $num);
// $( #[$attr] )*
// #[doc = use_desc_if_attr_is_empty!($desc, $(#[$attr])*)]
// #[allow(non_upper_case_globals)]
// pub const $name: Tag = Tag($ctx, $num);
define_tag_const_with_doc!($name, $ctx, $num, $desc,
$(#[$attr])*);
)+)+
}

Expand Down

0 comments on commit 3f5bb96

Please sign in to comment.