Skip to content

Commit 10677ce

Browse files
committed
cxx-qt-gen: enable missing_docs and fix missing docs
1 parent b0a9700 commit 10677ce

File tree

8 files changed

+28
-9
lines changed

8 files changed

+28
-9
lines changed

crates/cxx-qt-gen/src/generator/cpp/fragment.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44
// SPDX-License-Identifier: MIT OR Apache-2.0
55

66
#[derive(PartialEq, Eq, Debug)]
7+
/// A fragment of C++ code
78
pub enum CppFragment {
8-
Pair { header: String, source: String },
9+
/// A fragment which only both a header and a source
10+
Pair {
11+
/// The header of the fragment
12+
header: String,
13+
/// The source of the fragment
14+
source: String,
15+
},
16+
/// A fragment which only has a header
917
Header(String),
18+
/// A fragment which only has a source
1019
Source(String),
1120
}
1221

crates/cxx-qt-gen/src/generator/cpp/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub struct GeneratedCppBlocks {
3939
}
4040

4141
impl GeneratedCppBlocks {
42+
/// Create a [GeneratedCppBlocks] from the given [Parser] object
4243
pub fn from(parser: &Parser) -> Result<GeneratedCppBlocks> {
4344
let mut includes = BTreeSet::new();
4445

crates/cxx-qt-gen/src/generator/rust/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct GeneratedRustBlocks {
3333
}
3434

3535
impl GeneratedRustBlocks {
36+
/// Create a [GeneratedRustBlocks] from the given [Parser] object
3637
pub fn from(parser: &Parser) -> Result<GeneratedRustBlocks> {
3738
let mut fragments = vec![];
3839
fragments.extend(

crates/cxx-qt-gen/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
// SPDX-FileContributor: Gerhard de Clercq <[email protected]>
44
//
55
// SPDX-License-Identifier: MIT OR Apache-2.0
6+
7+
#![deny(missing_docs)]
8+
9+
//! The cxx-qt-gen crate provides methods for generated C++ and Rust code from a TokenStream.
10+
611
mod generator;
712
mod naming;
813
mod parser;
@@ -13,8 +18,8 @@ pub use generator::{
1318
cpp::{fragment::CppFragment, GeneratedCppBlocks},
1419
rust::GeneratedRustBlocks,
1520
};
16-
pub use parser::{qobject::QmlElementMetadata, Parser};
17-
pub use syntax::{parse_qt_file, CxxQtItem};
21+
pub use parser::Parser;
22+
pub use syntax::{parse_qt_file, CxxQtFile, CxxQtItem};
1823
pub use writer::{cpp::write_cpp, rust::write_rust};
1924

2025
pub use syn::{Error, Result};

crates/cxx-qt-gen/src/parser/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ use syn::{
3030
/// [syn::Item]'s that are not handled specially by CXX-Qt are passed through for CXX to process.
3131
pub struct Parser {
3232
/// The module which unknown (eg CXX) blocks are stored into
33-
pub passthrough_module: ItemMod,
33+
pub(crate) passthrough_module: ItemMod,
3434
/// Any CXX-Qt data that needs generation later
35-
pub cxx_qt_data: ParsedCxxQtData,
35+
pub(crate) cxx_qt_data: ParsedCxxQtData,
3636
/// all type names that were found in this module, including CXX types
37-
pub type_names: TypeNames,
37+
pub(crate) type_names: TypeNames,
3838
/// The stem of the file that the CXX headers for this module will be generated into
3939
pub cxx_file_stem: String,
4040
}

crates/cxx-qt-gen/src/syntax/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ mod qtitem;
1313
pub mod safety;
1414
pub mod types;
1515

16-
pub use qtfile::parse_qt_file;
16+
pub use qtfile::{parse_qt_file, CxxQtFile};
1717
pub use qtitem::CxxQtItem;

crates/cxx-qt-gen/src/syntax/qtfile.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ use quote::{ToTokens, TokenStreamExt};
99
use syn::parse::{Parse, ParseStream};
1010
use syn::{AttrStyle, Attribute, Result};
1111

12+
/// Representation of a CxxQtFile as Syn items
1213
pub struct CxxQtFile {
14+
/// A vector of [syn::Attribute] in the file
1315
pub attrs: Vec<Attribute>,
16+
/// A vector of [CxxQtItem] items in the file
1417
pub items: Vec<CxxQtItem>,
1518
}
1619

@@ -40,6 +43,7 @@ impl ToTokens for CxxQtFile {
4043
}
4144
}
4245

46+
/// Parse the given [std::path::Path] into a [CxxQtFile]
4347
pub fn parse_qt_file(path: impl AsRef<std::path::Path>) -> Result<CxxQtFile> {
4448
let source = std::fs::read_to_string(path.as_ref()).unwrap_or_else(|err| {
4549
// todo: fixme with a proper error propagation

crates/cxx-qt-gen/src/syntax/qtitem.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ use syn::parse::{Parse, ParseStream};
1010
use syn::{Attribute, Item, ItemMod, Result, Token, Visibility};
1111

1212
#[derive(Clone, PartialEq, Eq)]
13-
// This warning is triggered when running clippy on crates that depend on cxx-qt-gen,
14-
// but not when running clippy on cxx-qt-gen.
13+
/// Representation of either a Syn Item, a CXX module, or a CXX-Qt module
1514
pub enum CxxQtItem {
1615
/// A normal syntax item that we pass through
1716
Item(Item),

0 commit comments

Comments
 (0)