Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs usage links #653

Merged
merged 5 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Ph0enixKM marked this conversation as resolved.
Show resolved Hide resolved
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
Loading