Skip to content

Commit

Permalink
Apply some suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: Silvan Mosberger <[email protected]>
  • Loading branch information
hsjobeki and infinisil committed Feb 27, 2024
1 parent 629f1f7 commit 4b4ae1b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 55 deletions.
3 changes: 1 addition & 2 deletions doc/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ If arguments require more complex documentation consider starting an extra secti
# Arguments
## **x**
## **x** (Any)
(...Some comprehensive documentation)
*/
Expand Down
10 changes: 3 additions & 7 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ pub fn handle_indentation(raw: &str) -> Option<String> {
///
pub fn shift_headings(raw: &str, levels: usize) -> String {
let mut result = String::new();
for line in raw.lines() {
for line in raw.split_inclusive('\n') {
if line.trim_start().starts_with('#') {
result.push_str(&format!("{}\n", &handle_heading(line, levels)));
result.push_str(&handle_heading(line, levels));
} else {
result.push_str(&format!("{line}\n"));
result.push_str(line);
}
}
result
Expand All @@ -83,10 +83,6 @@ pub fn handle_heading(line: &str, levels: usize) -> String {
let mut rest = String::new();
for char in chars {
match char {
// ' ' | '\t' if hashes.is_empty() => {
// // only collect trivial before the initial hash
// leading_trivials.push(char)
// }
'#' if rest.is_empty() => {
// only collect hashes if no other tokens
hashes.push(char)
Expand Down
3 changes: 0 additions & 3 deletions src/snapshots/nixdoc__test__doc_comment.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ This is a parsed example

doc comment in markdown format


## `lib.debug.argumentTest` {#function-library-lib.debug.argumentTest}

doc comment in markdown format
Expand All @@ -33,7 +32,6 @@ Type: (Should NOT be a heading)

This is just markdown


structured function argument

: `formal1`
Expand All @@ -60,4 +58,3 @@ structured function argument
Comment



37 changes: 0 additions & 37 deletions test.nix

This file was deleted.

12 changes: 6 additions & 6 deletions test/headings.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

### h3-heading

### h4-heading
#### h4-heading

Should be h6
This should be h6

#### h5-heading
##### h5-heading

This should be h6
This should be h6 as well

##### h6-heading
###### h6-heading

This should be h6
This should be h6 as well

0 comments on commit 4b4ae1b

Please sign in to comment.