Skip to content

Commit

Permalink
doc(lib/pkg/pkg): add inline docs for Pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
comfysage committed Jan 26, 2024
1 parent 16b5dd6 commit 3237e25
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions saku-lib/pkg/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ use crate::pkg::flaskfile::PkgBuild;

use serde::{Serialize, Deserialize};

/// a package struct
///
/// - *name*: name of the package
/// - *desc*: short description
/// - *url*: url of the repo
/// - *group*: flask group of the package
/// - *path*: path to the flask file of the package
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Pkg {
#[serde(rename = "pkg")]
Expand All @@ -21,6 +28,10 @@ pub struct Pkg {
}

impl Pkg {
/// Create a new *Pkg*
///
/// - *name*: name of the package
/// - *url*: url of the repo
pub fn new(name: &str, url: &str) -> Self {
Self {
name: format!("{name}"),
Expand All @@ -34,6 +45,10 @@ impl Pkg {

// meta
impl Pkg {
/// Auto-fill *Pkg* fields
///
/// - *group* is infered from the path to the flask file
/// - *url* is extended using `util::url::extend_url`
pub fn fill(&mut self) -> Result<()> {
let local_path = self.get_path()?;
self.infer_group(local_path)?;
Expand All @@ -43,6 +58,9 @@ impl Pkg {

Ok(())
}
/// Infer group of a package
///
/// group is set to the dirname of the flask file of the package
pub fn infer_group(&mut self, path: String) -> Result<()> {
if self.group.len() > 0 {
return Ok(());
Expand Down

0 comments on commit 3237e25

Please sign in to comment.