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 5, 2023
1 parent ca92f93 commit 6e9ef69
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 31 deletions.
21 changes: 2 additions & 19 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 @@ -461,13 +450,7 @@ fn test_description_in_external_file() {
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,
);
let desc = retrieve_description(&nix, &"Line Comments", false, category);
writeln!(output, "{}", desc).expect("Failed to write header");

for entry in collect_entries(nix, category) {
Expand All @@ -487,7 +470,7 @@ fn test_description_of_lib_debug() {
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 6e9ef69

Please sign in to comment.