Skip to content

Commit e9f0546

Browse files
committed
docs: improve rustdoc coverage for public APIs
1 parent 39f0172 commit e9f0546

File tree

14 files changed

+108
-0
lines changed

14 files changed

+108
-0
lines changed

crates/cli/src/cli.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
//! Clap definitions for the Gitlane command-line interface.
2+
13
use std::path::PathBuf;
24

35
use clap::{Args, Parser, Subcommand, ValueEnum};
46

7+
/// Top-level Gitlane CLI arguments.
58
#[derive(Debug, Parser)]
69
#[command(
710
name = "gitlane",
@@ -10,93 +13,135 @@ use clap::{Args, Parser, Subcommand, ValueEnum};
1013
long_about = None
1114
)]
1215
pub struct Cli {
16+
/// Project directory or nested path used to locate `.gitlane`.
1317
#[arg(long, global = true, value_name = "PATH")]
1418
pub project: Option<PathBuf>,
1519

20+
/// Command to execute.
1621
#[command(subcommand)]
1722
pub command: Command,
1823
}
1924

25+
/// Supported top-level Gitlane commands.
2026
#[derive(Debug, Subcommand)]
2127
pub enum Command {
28+
/// Initialize a new Gitlane project scaffold.
2229
Init(InitArgs),
30+
/// Validate project configuration and data.
2331
Validate,
32+
/// Manage issues.
2433
Issue {
34+
/// Issue subcommand to execute.
2535
#[command(subcommand)]
2636
command: IssueCommand,
2737
},
38+
/// Inspect workflow configuration.
2839
Workflow {
40+
/// Workflow subcommand to execute.
2941
#[command(subcommand)]
3042
command: WorkflowCommand,
3143
},
44+
/// Inspect labels.
3245
Label {
46+
/// Label subcommand to execute.
3347
#[command(subcommand)]
3448
command: LabelCommand,
3549
},
3650
}
3751

52+
/// Arguments for `gitlane init`.
3853
#[derive(Debug, Args)]
3954
pub struct InitArgs {
55+
/// Project name to write into the generated config.
4056
#[arg(long)]
4157
pub name: Option<String>,
4258

59+
/// Optional project description for the generated config.
4360
#[arg(long)]
4461
pub description: Option<String>,
4562

63+
/// Optional homepage URL for the generated config.
4664
#[arg(long)]
4765
pub homepage: Option<String>,
4866

67+
/// Config file format to use for generated files.
4968
#[arg(long, value_enum)]
5069
pub format: Option<InitFormatArg>,
5170
}
5271

72+
/// Supported values for `gitlane init --format`.
5373
#[derive(Clone, Copy, Debug, ValueEnum)]
5474
pub enum InitFormatArg {
75+
/// Generate TOML config files.
5576
Toml,
77+
/// Generate JSON config files.
5678
Json,
79+
/// Generate YAML config files using `.yaml`.
5780
Yaml,
81+
/// Generate YAML config files using `.yml`.
5882
Yml,
5983
}
6084

85+
/// Supported `gitlane issue` subcommands.
6186
#[derive(Debug, Subcommand)]
6287
pub enum IssueCommand {
88+
/// Create a new issue.
6389
Create,
90+
/// List issues.
6491
List,
92+
/// Show one issue by id.
6593
Show(IssueShowArgs),
94+
/// Apply a workflow transition to an issue.
6695
Transition(IssueTransitionArgs),
6796
}
6897

98+
/// Arguments for `gitlane issue show`.
6999
#[derive(Debug, Args)]
70100
pub struct IssueShowArgs {
101+
/// Issue identifier to display.
71102
pub id: String,
72103
}
73104

105+
/// Arguments for `gitlane issue transition`.
74106
#[derive(Debug, Args)]
75107
pub struct IssueTransitionArgs {
108+
/// Issue identifier to transition.
76109
pub id: String,
110+
/// Transition identifier to apply.
77111
pub transition_id: String,
78112
}
79113

114+
/// Supported `gitlane workflow` subcommands.
80115
#[derive(Debug, Subcommand)]
81116
pub enum WorkflowCommand {
117+
/// Show the full workflow configuration.
82118
Show,
119+
/// List workflow states.
83120
States,
121+
/// List transitions, optionally filtered by source state.
84122
Transitions(WorkflowTransitionsArgs),
85123
}
86124

125+
/// Arguments for `gitlane workflow transitions`.
87126
#[derive(Debug, Args)]
88127
pub struct WorkflowTransitionsArgs {
128+
/// Optional source state id to filter transitions.
89129
#[arg(long = "from", value_name = "STATE_ID")]
90130
pub from_state: Option<String>,
91131
}
92132

133+
/// Supported `gitlane label` subcommands.
93134
#[derive(Debug, Subcommand)]
94135
pub enum LabelCommand {
136+
/// List labels.
95137
List,
138+
/// Show one label by id.
96139
Show(LabelShowArgs),
97140
}
98141

142+
/// Arguments for `gitlane label show`.
99143
#[derive(Debug, Args)]
100144
pub struct LabelShowArgs {
145+
/// Label identifier to display.
101146
pub id: String,
102147
}

crates/cli/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Gitlane command-line entry point.
2+
13
mod cli;
24
mod path;
35

crates/cli/src/path.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Helpers for resolving the active Gitlane project directory.
2+
13
use std::{
24
ffi::OsStr,
35
path::{Path, PathBuf},
@@ -9,6 +11,7 @@ use gitlane::{
911
paths::GITLANE_DIR,
1012
};
1113

14+
/// Resolves the nearest `.gitlane` directory from `start_path` or its parents.
1215
pub fn resolve_project(start_path: &Path) -> anyhow::Result<PathBuf> {
1316
let start = start_path
1417
.canonicalize()

crates/core/src/config.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Config file discovery and format helpers for Gitlane project data.
2+
13
use std::path::{Path, PathBuf};
24

35
use thiserror::Error;
@@ -19,9 +21,13 @@ pub const ISSUES_WORKFLOW_CONFIG_STEM: &str = "workflow";
1921
/// Logical config file kinds supported by Gitlane.
2022
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2123
pub enum ConfigKind {
24+
/// Project metadata config stored at the project root.
2225
Project,
26+
/// Issue tracker config stored under `.gitlane/issues`.
2327
Issues,
28+
/// Issue labels config stored under `.gitlane/issues`.
2429
IssuesLabels,
30+
/// Issue workflow config stored under `.gitlane/issues`.
2531
IssuesWorkflow,
2632
}
2733

@@ -40,19 +46,26 @@ impl ConfigKind {
4046
/// File extensions accepted for config files.
4147
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4248
pub enum ConfigFileExtension {
49+
/// TOML config files.
4350
Toml,
51+
/// JSON config files.
4452
Json,
53+
/// YAML config files using the `.yaml` extension.
4554
Yaml,
55+
/// YAML config files using the `.yml` extension.
4656
Yml,
4757
}
4858

4959
/// Parser-specific errors for supported config formats.
5060
#[derive(Debug, Error)]
5161
pub enum ConfigParseError {
62+
/// TOML parser error.
5263
#[error(transparent)]
5364
Toml(#[from] toml::de::Error),
65+
/// JSON parser error.
5466
#[error(transparent)]
5567
Json(#[from] serde_json::Error),
68+
/// YAML parser error.
5669
#[error(transparent)]
5770
Yaml(#[from] serde_yaml::Error),
5871
}
@@ -70,10 +83,13 @@ impl ConfigParseError {
7083
/// Serializer-specific errors for supported config formats.
7184
#[derive(Debug, Error)]
7285
pub enum ConfigSerializeError {
86+
/// TOML serializer error.
7387
#[error(transparent)]
7488
Toml(#[from] toml_edit::ser::Error),
89+
/// JSON serializer error.
7590
#[error(transparent)]
7691
Json(#[from] serde_json::Error),
92+
/// YAML serializer error.
7793
#[error(transparent)]
7894
Yaml(#[from] serde_yaml::Error),
7995
}

crates/core/src/errors.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Shared error types for Gitlane core operations.
2+
13
use std::path::{Path, PathBuf};
24

35
use thiserror::Error;
@@ -14,44 +16,55 @@ use crate::{
1416
/// Top-level error type for Gitlane core operations.
1517
#[derive(Debug, Error)]
1618
pub enum GitlaneError {
19+
/// The provided project name was empty or whitespace-only.
1720
#[error("project name must be a non-empty, non-whitespace string")]
1821
InvalidProjectName,
22+
/// Initialization was attempted where a project config already exists.
1923
#[error("project already exists at `{path}`")]
2024
ProjectAlreadyExists { path: PathBuf },
25+
/// A required logical config file was not found.
2126
#[error("missing supported {config_name} config file in `{directory}`")]
2227
MissingConfigFile {
2328
config_name: &'static str,
2429
directory: PathBuf,
2530
},
31+
/// More than one supported file exists for the same logical config.
2632
#[error("found multiple supported {config_name} config files: {paths:?}")]
2733
AmbiguousConfigFiles {
2834
config_name: &'static str,
2935
paths: Vec<PathBuf>,
3036
},
37+
/// A config file path did not use a supported extension.
3138
#[error("unsupported config format for `{path}`; expected .toml, .json, .yaml, or .yml")]
3239
UnsupportedConfigFormat { path: PathBuf },
40+
/// A config file parsed but failed semantic validation.
3341
#[error("invalid config in `{path}`: {message}")]
3442
InvalidConfig { path: PathBuf, message: String },
43+
/// Parsing a config file failed.
3544
#[error("failed to parse `{path}` as {format}", format = .source.format_name())]
3645
ParseConfig {
3746
path: PathBuf,
3847
#[source]
3948
source: ConfigParseError,
4049
},
50+
/// Serializing a config file failed.
4151
#[error("failed to serialize `{path}` as {format}", format = .source.format_name())]
4252
SerializeConfig {
4353
path: PathBuf,
4454
#[source]
4555
source: ConfigSerializeError,
4656
},
57+
/// Issue front matter parsed but failed semantic validation.
4758
#[error("invalid front matter in `{path}`: {message}")]
4859
InvalidFrontmatter { path: PathBuf, message: String },
60+
/// Parsing issue front matter failed.
4961
#[error("failed to parse front matter in `{path}` as {format}", format = .source.format_name())]
5062
ParseFrontmatter {
5163
path: PathBuf,
5264
#[source]
5365
source: FrontmatterParseError,
5466
},
67+
/// Serializing issue front matter failed.
5568
#[error(
5669
"failed to serialize front matter in `{path}` as {format}",
5770
format = .source.format_name()
@@ -61,8 +74,10 @@ pub enum GitlaneError {
6174
#[source]
6275
source: FrontmatterSerializeError,
6376
},
77+
/// Parsed issue metadata failed semantic validation.
6478
#[error("invalid issue in `{path}`: {message}")]
6579
InvalidIssue { path: PathBuf, message: String },
80+
/// A filesystem operation failed.
6681
#[error(transparent)]
6782
Filesystem(#[from] FsError),
6883
}

crates/core/src/frontmatter.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ pub(crate) const JSON_OBJECT_END: char = '}';
1414
/// Parser-specific errors for supported front matter formats.
1515
#[derive(Debug, Error)]
1616
pub enum FrontmatterParseError {
17+
/// TOML front matter parser error.
1718
#[error(transparent)]
1819
Toml(#[from] toml::de::Error),
20+
/// TOML document parser error used for editable TOML front matter.
1921
#[error(transparent)]
2022
TomlDocument(#[from] toml_edit::TomlError),
23+
/// JSON front matter parser error.
2124
#[error(transparent)]
2225
Json(#[from] serde_json::Error),
26+
/// YAML front matter parser error.
2327
#[error(transparent)]
2428
Yaml(#[from] serde_yaml::Error),
2529
}
@@ -38,10 +42,13 @@ impl FrontmatterParseError {
3842
/// Serializer-specific errors for supported front matter formats.
3943
#[derive(Debug, Error)]
4044
pub enum FrontmatterSerializeError {
45+
/// Timestamp formatting error while rendering front matter.
4146
#[error(transparent)]
4247
TimeFormat(#[from] time::error::Format),
48+
/// JSON front matter serializer error.
4349
#[error(transparent)]
4450
Json(#[from] serde_json::Error),
51+
/// YAML front matter serializer error.
4552
#[error(transparent)]
4653
Yaml(#[from] serde_yaml::Error),
4754
}
@@ -80,10 +87,14 @@ pub(crate) enum FrontmatterError {
8087
Parse(#[from] FrontmatterParseError),
8188
}
8289

90+
/// Supported serialized front matter formats for issue documents.
8391
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8492
pub enum FrontmatterFormat {
93+
/// TOML front matter delimited by `+++` fences.
8594
Toml,
95+
/// JSON front matter stored as a top-level object.
8696
Json,
97+
/// YAML front matter delimited by `---` fences.
8798
Yaml,
8899
}
89100

crates/core/src/issues/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Validated issue tracker config types and rules.
2+
13
use std::{
24
collections::{BTreeMap, HashSet},
35
path::Path,

crates/core/src/issues/issue/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Typed issue document parsing, validation, and persistence.
2+
13
use std::{collections::HashSet, path::Path};
24

35
use thiserror::Error;

crates/core/src/issues/labels/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Validated issue label config types and rules.
2+
13
use std::{collections::BTreeMap, path::Path};
24

35
use crate::{

crates/core/src/issues/templates.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Built-in issue template scaffolding helpers.
2+
13
use crate::config::ConfigFileExtension;
24
use crate::frontmatter::{JSON_OBJECT_END, JSON_OBJECT_START, TOML_FENCE, YAML_FENCE};
35

0 commit comments

Comments
 (0)