Skip to content

Commit

Permalink
remove --description_file
Browse files Browse the repository at this point in the history
  • Loading branch information
phaer committed Sep 6, 2023
1 parent ca92f93 commit db8692e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 50 deletions.
39 changes: 1 addition & 38 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ struct Options {
#[arg(long)]
description_extract: bool,

/// Extract the description of the function category from the given markdown file.
#[arg(long)]
description_file: Option<PathBuf>,

/// Nix file to process.
#[arg(short, long)]
file: PathBuf,
Expand Down Expand Up @@ -374,7 +370,6 @@ fn retrieve_description(
nix: &rnix::Root,
description: &str,
description_extract: bool,
description_file: Option<PathBuf>,
category: &str,
) -> String {
if description_extract {
Expand All @@ -384,11 +379,6 @@ fn retrieve_description(
.and_then(|node| retrieve_doc_comment(&node, true))
.expect("could not read description from top-level comment"),
)
} else if let Some(filename) = description_file {
let content = fs::read_to_string(&filename).unwrap_or_else(|e| {
panic!("could not read description from \"{:?}\": {}", filename, e)
});
dedent(&content)
} else {
format!(
"# {} {{#sec-functions-library-{}}}\n",
Expand All @@ -413,7 +403,6 @@ fn main() {
&nix,
&opts.description,
opts.description_extract,
opts.description_file,
&opts.category,
);

Expand Down Expand Up @@ -455,39 +444,13 @@ fn test_main() {
insta::assert_snapshot!(output);
}

#[test]
fn test_description_in_external_file() {
let mut output = Vec::new();
let src = fs::read_to_string("test/line-comments.nix").unwrap();
let nix = rnix::Root::parse(&src).ok().expect("failed to parse input");
let category = "line-comments";
let desc = retrieve_description(
&nix,
&"",
false,
Some("test/line-comments.md".into()),
category,
);
writeln!(output, "{}", desc).expect("Failed to write header");

for entry in collect_entries(nix, category) {
entry
.write_section(&Default::default(), &mut output)
.expect("Failed to write section")
}

let output = String::from_utf8(output).expect("not utf8");

insta::assert_snapshot!(output);
}

#[test]
fn test_description_of_lib_debug() {
let mut output = Vec::new();
let src = fs::read_to_string("test/lib-debug.nix").unwrap();
let nix = rnix::Root::parse(&src).ok().expect("failed to parse input");
let category = "debug";
let desc = retrieve_description(&nix, &"", true, None, category);
let desc = retrieve_description(&nix, &"", true, category);
writeln!(output, "{}", desc).expect("Failed to write header");

for entry in collect_entries(nix, category) {
Expand Down
7 changes: 1 addition & 6 deletions src/snapshots/nixdoc__description_in_external_file.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
source: src/main.rs
expression: output
---
# Line Comments

This a markdown document which could describe
the inner workings of [lines-comments.nix](./line-comments.nix) if
it wasn't a simple test-fixture for
`--description file:line-comments.md`.
# Line Comments {#sec-functions-library-line-comments}

## `lib.line-comments.shown` {#function-library-lib.line-comments.shown}

Expand Down
6 changes: 0 additions & 6 deletions test/line-comments.md

This file was deleted.

0 comments on commit db8692e

Please sign in to comment.