Skip to content

Commit

Permalink
Improve docs usage links (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
hdwalters authored Jan 7, 2025
1 parent 665cdc1 commit aa4f61d
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 10 deletions.
22 changes: 17 additions & 5 deletions src/modules/function/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ impl DocumentationModule for FunctionDeclaration {
for reference in references {
result.push(reference);
}
result.push("\n".to_string());
result.push("".to_string());
}
result.push("".to_string());
result.join("\n")
}
}
Expand Down Expand Up @@ -317,13 +318,24 @@ impl FunctionDeclaration {
result.push(String::from("```\n"));
if test_path.exists() && test_path.is_dir() {
if let Ok(entries) = fs::read_dir(test_path) {
let pattern = format!("{}*.ab", self.name);
let pattern = glob::Pattern::new(&pattern).unwrap();
let pattern1 = {
let pattern = format!("{}*.ab", self.name);
glob::Pattern::new(&pattern).unwrap()
};
let pattern2 = {
let pattern = format!("{}_{}*.ab", lib_name, self.name);
glob::Pattern::new(&pattern).unwrap()
};
for entry in entries.flatten() {
let path = entry.path();
if let Some(file_name) = path.file_name().and_then(OsStr::to_str) {
if pattern.matches(file_name) {
references.push(format!("* [{}](https://github.com/amber-lang/amber/blob/{}/src/tests/stdlib/{})", file_name, env!("CARGO_PKG_VERSION"), file_name));
if pattern1.matches(file_name) || pattern2.matches(file_name) {
references.push(format!(
"* [{}](https://github.com/amber-lang/amber/blob/{}/src/tests/stdlib/{})",
file_name,
env!("CARGO_PKG_VERSION"),
file_name,
));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/statement/comment_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ impl TranslateModule for CommentDoc {

impl DocumentationModule for CommentDoc {
fn document(&self, _meta: &ParserMetadata) -> String {
self.value.clone() + "\n\n"
self.value.trim_end().to_string() + "\n"
}
}
6 changes: 3 additions & 3 deletions src/std/fs.ab
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ pub fun dir_create(path: Text): Null {
}
}

/// Sets a file as executable.
/// Changes the permission bits of a file.
///
/// If the file doesn't exist, it returns a boolean and prints a message.
/// If the file doesn't exist, it returns `false` and prints a message.
pub fun file_chmod(path: Text, mode: Text): Bool {
if file_exists(path) {
trust $ chmod "{mode}" "{path}" $
Expand All @@ -69,7 +69,7 @@ pub fun file_chmod(path: Text, mode: Text): Bool {

/// Changes the owner of a file.
///
/// If the file doesn't exist, it returns `false`
/// If the file doesn't exist, it returns `false` and prints a message.
pub fun file_chown(path: Text, user: Text): Bool {
if file_exists(path) or dir_exists(path) {
trust $ chown -R "{user}" "{path}" $
Expand Down
2 changes: 1 addition & 1 deletion src/std/text.ab
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fun split_words(text: Text): [Text] {
return split(text, " ")
}

/// Merges text using the delimeter specified.
/// Merges text using the delimiter specified.
pub fun join(list: [Text], delimiter: Text): Text {
return trust $ IFS="{delimiter}" ; echo "\$\{{nameof list}[*]}" $
}
Expand Down

0 comments on commit aa4f61d

Please sign in to comment.