Skip to content

Commit

Permalink
[codegen] Also just reproduce the original docs when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyr committed Oct 31, 2023
1 parent 1244fcd commit 1c9a234
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 23 deletions.
6 changes: 5 additions & 1 deletion font-codegen/src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,12 +812,16 @@ impl Field {
quote!(let args = #args;)
});

let original_docs = &self.attrs.docs;

let extra_docs_if_input_data = input_data_if_needed.is_some().then(|| {
quote! {
#[doc = ""]
#[doc = " The `data` argument should generally be retrieved via the `offset_data`"]
#[doc = " method of the parent table, but you should consult the docs of the"]
#[doc = " referenced method for more information."]
#[doc = " referenced method (reproduced below)"]
#[doc = ""]
#(#original_docs)*
}
});
if self.is_array() {
Expand Down
18 changes: 14 additions & 4 deletions read-fonts/generated/generated_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ impl BaseScriptRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to BaseScript table, from beginning of BaseScriptList
pub fn base_script<'a>(&self, data: FontData<'a>) -> Result<BaseScript<'a>, ReadError> {
self.base_script_offset().resolve(data)
}
Expand Down Expand Up @@ -576,7 +578,9 @@ impl BaseLangSysRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to MinMax table, from beginning of BaseScript table
pub fn min_max<'a>(&self, data: FontData<'a>) -> Result<MinMax<'a>, ReadError> {
self.min_max_offset().resolve(data)
}
Expand Down Expand Up @@ -873,7 +877,10 @@ impl FeatMinMaxRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to BaseCoord table that defines the minimum extent
/// value, from beginning of MinMax table (may be NULL)
pub fn min_coord<'a>(&self, data: FontData<'a>) -> Option<Result<MinMax<'a>, ReadError>> {
self.min_coord_offset().resolve(data)
}
Expand All @@ -888,7 +895,10 @@ impl FeatMinMaxRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to BaseCoord table that defines the maximum extent
/// value, from beginning of MinMax table (may be NULL)
pub fn max_coord<'a>(&self, data: FontData<'a>) -> Option<Result<MinMax<'a>, ReadError>> {
self.max_coord_offset().resolve(data)
}
Expand Down
15 changes: 12 additions & 3 deletions read-fonts/generated/generated_cmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ impl EncodingRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Byte offset from beginning of table to the subtable for this
/// encoding.
pub fn subtable<'a>(&self, data: FontData<'a>) -> Result<CmapSubtable<'a>, ReadError> {
self.subtable_offset().resolve(data)
}
Expand Down Expand Up @@ -1642,7 +1645,10 @@ impl VariationSelector {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset from the start of the format 14 subtable to Default UVS
/// Table. May be 0.
pub fn default_uvs<'a>(&self, data: FontData<'a>) -> Option<Result<DefaultUvs<'a>, ReadError>> {
self.default_uvs_offset().resolve(data)
}
Expand All @@ -1657,7 +1663,10 @@ impl VariationSelector {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset from the start of the format 14 subtable to Non-Default
/// UVS Table. May be 0.
pub fn non_default_uvs<'a>(
&self,
data: FontData<'a>,
Expand Down
8 changes: 6 additions & 2 deletions read-fonts/generated/generated_colr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,9 @@ impl BaseGlyphPaint {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to a Paint table.
pub fn paint<'a>(&self, data: FontData<'a>) -> Result<Paint<'a>, ReadError> {
self.paint_offset().resolve(data)
}
Expand Down Expand Up @@ -743,7 +745,9 @@ impl Clip {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to a ClipBox table.
pub fn clip_box<'a>(&self, data: FontData<'a>) -> Result<ClipBox<'a>, ReadError> {
self.clip_box_offset().resolve(data)
}
Expand Down
32 changes: 26 additions & 6 deletions read-fonts/generated/generated_gpos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,9 @@ impl MarkRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to Anchor table, from beginning of MarkArray table.
pub fn mark_anchor<'a>(&self, data: FontData<'a>) -> Result<AnchorTable<'a>, ReadError> {
self.mark_anchor_offset().resolve(data)
}
Expand Down Expand Up @@ -2241,7 +2243,10 @@ impl EntryExitRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to entryAnchor table, from beginning of CursivePos
/// subtable (may be NULL).
pub fn entry_anchor<'a>(
&self,
data: FontData<'a>,
Expand All @@ -2259,7 +2264,10 @@ impl EntryExitRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to exitAnchor table, from beginning of CursivePos
/// subtable (may be NULL).
pub fn exit_anchor<'a>(
&self,
data: FontData<'a>,
Expand Down Expand Up @@ -2577,7 +2585,11 @@ impl<'a> BaseRecord<'a> {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Array of offsets (one per mark class) to Anchor tables. Offsets
/// are from beginning of BaseArray table, ordered by class
/// (offsets may be NULL).
pub fn base_anchors(
&self,
data: FontData<'a>,
Expand Down Expand Up @@ -3036,7 +3048,11 @@ impl<'a> ComponentRecord<'a> {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Array of offsets (one per class) to Anchor tables. Offsets are
/// from beginning of LigatureAttach table, ordered by class
/// (offsets may be NULL).
pub fn ligature_anchors(
&self,
data: FontData<'a>,
Expand Down Expand Up @@ -3381,7 +3397,11 @@ impl<'a> Mark2Record<'a> {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Array of offsets (one per class) to Anchor tables. Offsets are
/// from beginning of Mark2Array table, in class order (offsets may
/// be NULL).
pub fn mark2_anchors(
&self,
data: FontData<'a>,
Expand Down
22 changes: 17 additions & 5 deletions read-fonts/generated/generated_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ impl ScriptRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to Script table, from beginning of ScriptList
pub fn script<'a>(&self, data: FontData<'a>) -> Result<Script<'a>, ReadError> {
self.script_offset().resolve(data)
}
Expand Down Expand Up @@ -264,7 +266,9 @@ impl LangSysRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to LangSys table, from beginning of Script table
pub fn lang_sys<'a>(&self, data: FontData<'a>) -> Result<LangSys<'a>, ReadError> {
self.lang_sys_offset().resolve(data)
}
Expand Down Expand Up @@ -494,7 +498,9 @@ impl FeatureRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to Feature table, from beginning of FeatureList
pub fn feature<'a>(&self, data: FontData<'a>) -> Result<Feature<'a>, ReadError> {
let args = self.feature_tag();
self.feature_offset().resolve_with_args(data, &args)
Expand Down Expand Up @@ -3926,7 +3932,10 @@ impl FeatureVariationRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to a condition set table, from beginning of
/// FeatureVariations table.
pub fn condition_set<'a>(
&self,
data: FontData<'a>,
Expand All @@ -3944,7 +3953,10 @@ impl FeatureVariationRecord {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
/// Offset to a feature table substitution table, from beginning of
/// the FeatureVariations table.
pub fn feature_table_substitution<'a>(
&self,
data: FontData<'a>,
Expand Down
6 changes: 4 additions & 2 deletions read-fonts/generated/generated_test_records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ impl ContainsOffests {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
pub fn array<'a>(&self, data: FontData<'a>) -> Result<&'a [SimpleRecord], ReadError> {
let args = self.off_array_count();
self.array_offset().resolve_with_args(data, &args)
Expand All @@ -276,7 +277,8 @@ impl ContainsOffests {
///
/// The `data` argument should generally be retrieved via the `offset_data`
/// method of the parent table, but you should consult the docs of the
/// referenced method for more information.
/// referenced method (reproduced below)
///
pub fn other<'a>(&self, data: FontData<'a>) -> Result<BasicTable<'a>, ReadError> {
self.other_offset().resolve(data)
}
Expand Down

0 comments on commit 1c9a234

Please sign in to comment.