Skip to content

Commit 2beacd4

Browse files
committed
Merge branch 'feature/improve-docs' into develop
2 parents 6f3736a + 485f635 commit 2beacd4

File tree

11 files changed

+86
-25
lines changed

11 files changed

+86
-25
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
* Documents are improved a little.
6+
57
## [0.4.3]
68

79
* Longer lifetime for iterator returned by

src/low/v7400/attribute/value.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use crate::low::v7400::AttributeType;
1313
/// * `get_*_or_type()` returns `Result<_, AttributeType>`.
1414
/// + If a value of the expected type available, returns `Ok(_)`.
1515
/// + If not, returns `Ok(ty)` where `ty` is value type (same value as
16-
/// returned by `type_()`.
16+
/// returned by [`type_()`][`type_`].
17+
///
18+
/// [`type_`]: #method.type_
1719
#[derive(Debug, Clone, PartialEq)]
1820
pub enum AttributeValue {
1921
/// Single `bool`.

src/pull_parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! These modules are common among all supported FBX versions:
88
//!
99
//! * Error types (defined in [`error`] module).
10-
//! * `AnyParser` feature (defined in [`any`] module).
10+
//! * [`AnyParser`] feature (defined in [`any`] module).
1111
//! * Parser source traits and wrappers (defined in [`reader`] module).
1212
//!
1313
//! # Using pull parser
@@ -85,6 +85,7 @@
8585
//! [`any`]: any/index.html
8686
//! [`error`]: error/index.html
8787
//! [`reader`]: reader/index.html
88+
//! [`AnyParser`]: any/enum.AnyParser.html
8889
8990
pub use self::{
9091
error::{Error, Result, Warning},

src/pull_parser/any.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ fn parser_version(header: FbxHeader) -> Result<ParserVersion> {
5050

5151
/// Loads a tree from the given reader.
5252
///
53-
/// This works for seekable readers (which implement `std::io::Seek`), but
54-
/// `from_seekable_reader` should be used for them, because it is more efficent.
53+
/// This works for seekable readers (which implement [`std::io::Seek`]), but
54+
/// [`from_seekable_reader`] should be used for them, because it is more
55+
/// efficent.
56+
///
57+
/// [`std::io::Seek`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html
58+
/// [`from_seekable_reader`]: fn.from_seekable_reader.html
5559
pub fn from_reader<R: Read>(mut reader: R) -> Result<AnyParser<PlainSource<R>>> {
5660
let header = FbxHeader::load(&mut reader)?;
5761
match parser_version(header)? {

src/pull_parser/error.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Error {
4747
self.repr.position.as_ref()
4848
}
4949

50-
/// Creates a new `error` with the given syntactic position info.
50+
/// Creates a new `Error` with the given syntactic position info.
5151
pub(crate) fn with_position(error: ErrorContainer, position: SyntacticPosition) -> Self {
5252
Self {
5353
repr: Box::new(Repr::with_position(error, position)),
@@ -117,18 +117,27 @@ pub enum ErrorKind {
117117
/// Invalid data.
118118
///
119119
/// With this error kind, the inner error must be [`DataError`].
120+
///
121+
/// [`DataError`]: enum.DataError.html
120122
Data,
121123
/// I/O error.
122124
///
123125
/// With this error kind, the inner error must be [`std::io::Error`].
126+
///
127+
/// [`std::io::Error`]:
128+
/// https://doc.rust-lang.org/stable/std/io/struct.Error.html
124129
Io,
125130
/// Invalid operation.
126131
///
127132
/// With this error kind, the inner error must be [`OperationError`].
133+
///
134+
/// [`OperationError`]: enum.OperationError.html
128135
Operation,
129136
/// Critical warning.
130137
///
131138
/// With this error kind, the inner error must be [`Warning`].
139+
///
140+
/// [`Warning`]: enum.Warning.html
132141
Warning,
133142
}
134143

src/pull_parser/reader.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@ pub trait ParserSource: Sized + io::Read {
3434
/// This is called many times during parsing, so it is desirable to be fast
3535
/// as possible.
3636
///
37-
/// Reader types with `std::io::Seek` can implement this as
37+
/// Reader types with [`std::io::Seek`] can implement this as
3838
/// `self.seek(SeekFrom::Current(0)).unwrap()`, but this is fallible and
3939
/// can be inefficient.
4040
/// Use of [`PositionCacheReader`] is reccomended.
4141
///
42+
/// [`std::io::Seek`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html
4243
/// [`PositionCacheReader`]: struct.PositionCacheReader.html
4344
fn position(&self) -> u64;
4445

4546
/// Skips (seeks formward) the given size.
4647
///
47-
/// Reader types can make this more efficient using `io::Seek::seek` if
48-
/// possible.
48+
/// Reader types can make this more efficient using [`std::io::Seek::seek`]
49+
/// if possible.
4950
///
5051
/// # Examples
5152
///
@@ -61,6 +62,9 @@ pub trait ParserSource: Sized + io::Read {
6162
/// reader.skip_distance(7).expect("Failed to skip");
6263
/// assert_eq!(reader.position(), 7);
6364
/// ```
65+
///
66+
/// [`std::io::Seek::seek`]:
67+
/// https://doc.rust-lang.org/stable/std/io/trait.Seek.html#tymethod.seek
6468
fn skip_distance(&mut self, distance: u64) -> io::Result<()> {
6569
// NOTE: `let mut limited = self.by_ref().take(distance);` is E0507.
6670
let mut limited = io::Read::take(self.by_ref(), distance);
@@ -70,8 +74,8 @@ pub trait ParserSource: Sized + io::Read {
7074

7175
/// Skips (seeks forward) to the given position.
7276
///
73-
/// Reader types can make this more efficient using `io::Seek::seek` if
74-
/// possible.
77+
/// Reader types can make this more efficient using [`std::io::Seek::seek`]
78+
/// if possible.
7579
///
7680
/// # Panics
7781
///
@@ -91,6 +95,9 @@ pub trait ParserSource: Sized + io::Read {
9195
/// reader.skip_to(7).expect("Failed to skip");
9296
/// assert_eq!(reader.position(), 7);
9397
/// ```
98+
///
99+
/// [`std::io::Seek::seek`]:
100+
/// https://doc.rust-lang.org/stable/std/io/trait.Seek.html#tymethod.seek
94101
fn skip_to(&mut self, pos: u64) -> io::Result<()> {
95102
let distance = pos
96103
.checked_sub(self.position())

src/pull_parser/reader/position_cache.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ pub struct PositionCacheReader<R> {
2020
}
2121

2222
impl<R: io::Read> PositionCacheReader<R> {
23-
/// Creates a new `PositionCache`.
23+
/// Creates a new `PositionCacheReader`.
2424
pub fn new(inner: R) -> Self {
2525
Self { inner, position: 0 }
2626
}
2727

28-
/// Creates a new `PositionCache` with the given offset.
28+
/// Creates a new `PositionCacheReader` with the given offset.
2929
///
3030
/// # Examples
3131
///
@@ -62,7 +62,7 @@ impl<R: io::Read> PositionCacheReader<R> {
6262
///
6363
/// A seek beyond the end of a stream is allowed, but behavior is defined by
6464
/// the implementation.
65-
/// See the document for `std::io::Seek::seek()`.
65+
/// See the document for [`std::io::Seek::seek()`][`std::io::Seek::seek`].
6666
///
6767
/// # Examples
6868
///
@@ -79,6 +79,9 @@ impl<R: io::Read> PositionCacheReader<R> {
7979
/// reader.skip_distance(7).expect("Failed to skip");
8080
/// assert_eq!(reader.position(), 7);
8181
/// ```
82+
///
83+
/// [`std::io::Seek::seek`]:
84+
/// https://doc.rust-lang.org/stable/std/io/trait.Seek.html#tymethod.seek
8285
pub fn skip_distance(&mut self, mut distance: u64) -> io::Result<()>
8386
where
8487
R: io::Seek,

src/pull_parser/reader/source.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ use crate::pull_parser::{reader::PositionCacheReader, ParserSource};
88
///
99
/// This may be inefficient, but works with any reader types.
1010
/// It is recommended to use [`SeekableSource`] if the reader implements
11-
/// `std::io::Seek`.
11+
/// [`std::io::Seek`].
1212
///
1313
/// This internally uses `PositionCacheReader`, so users don't need to wrap
1414
/// readers by `PositionCacheReader` manually.
1515
///
16+
/// [`std::io::Seek`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html
1617
/// [`PositionCacheReader`]: struct.PositionCacheReader.html
1718
/// [`SeekableSource`]: struct.SeekableSource.html
1819
#[derive(Debug, Clone, Copy)]

src/pull_parser/v7400/attribute.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use crate::{
1414
use self::array::{ArrayAttributeValues, AttributeStreamDecoder, BooleanArrayAttributeValues};
1515
pub use self::loader::LoadAttribute;
1616

17-
/// Use `low::v7400::AttributeValue` instead.
17+
/// Use [`low::v7400::AttributeValue`] instead.
18+
///
19+
/// [`low::v7400::AttributeValue`]: ../../../low/v7400/enum.AttributeValue.html
1820
#[deprecated(
1921
since = "0.4.0",
2022
note = "`DirectAttributeValue` is moved to `low::v7400::AttributeValue`"

src/pull_parser/v7400/attribute/loaders/single.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::pull_parser::{v7400::LoadAttribute, Result};
66

77
/// Loader for primitive types.
88
///
9-
/// Supported types are: [`bool`], [`i16`] , [`i32`], [`i64`], [`f32`], [`f64`].
9+
/// Supported types are: `bool`, `i16` , `i32`, `i64`, `f32`, and `f64`.
1010
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
1111
pub struct PrimitiveLoader<T>(std::marker::PhantomData<T>);
1212

0 commit comments

Comments
 (0)