Skip to content

Commit

Permalink
Convert .md files to .toml files
Browse files Browse the repository at this point in the history
a407f82 split features.toml into many
.md files with TOML frontmatters. This commit converts all .md files in
the data/ directory to .toml files so that they can be more easily
processed by other software.

Closes #30.
  • Loading branch information
not-my-profile committed Nov 26, 2021
1 parent c6ae827 commit 1fc4439
Show file tree
Hide file tree
Showing 1,063 changed files with 2,571 additions and 3,657 deletions.
40 changes: 8 additions & 32 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use std::{
default::Default,
env,
fmt::Debug,
io::{BufRead, BufReader, BufWriter, Write},
io::{BufWriter, Write},
iter,
path::Path,
};

use anyhow::{bail, Context as _};
use anyhow::Context as _;
use fs_err::{self as fs, DirEntry, File};
use proc_macro2::{Ident, Span, TokenStream};
use quote::{quote, ToTokens};
Expand Down Expand Up @@ -192,41 +192,17 @@ fn collect_features(
continue;
}

let slug = match file_name.strip_suffix(".md") {
let slug = match file_name.strip_suffix(".toml") {
Some(basename) => basename.to_owned(),
None => {
panic!("expected only .md files and version.toml in data/*, found `{}`", file_name,)
panic!(
"expected only .toml files and version.toml in data/*, found `{}`",
file_name,
)
}
};
let feature_file = BufReader::new(File::open(file.path())?);

let mut feature_file_lines = feature_file.lines();
let mut feature_file_frontmatter = String::new();
assert_eq!(
match feature_file_lines.next() {
Some(Ok(s)) => s,
_ => bail!("reading first line of data/{}/{} failed", dir_name, file_name),
},
"+++",
"expected frontmatter at the beginning of data/{}/{}",
dir_name,
file_name
);

loop {
match feature_file_lines.next() {
Some(Ok(s)) if s == "+++" => break,
Some(Ok(s)) => {
feature_file_frontmatter += s.as_str();
feature_file_frontmatter.push('\n');
}
_ => bail!("reading frontmatter of data/{}/{} failed", dir_name, file_name),
}
}

// TODO: Read file contents after frontmatter

let feature = toml::from_str(&feature_file_frontmatter).with_context(|| {
let feature = toml::from_str(&fs::read_to_string(file.path())?).with_context(|| {
format!("deserializing frontmatter of data/{}/{}", dir_name, file_name)
})?;

Expand Down
4 changes: 0 additions & 4 deletions data/1.0/associated_types.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.0/associated_types.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "associated types in traits"
flag = "associated_types"
4 changes: 0 additions & 4 deletions data/1.0/default_type_params.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.0/default_type_params.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "type parameter defaults"
flag = "default_type_params"
4 changes: 0 additions & 4 deletions data/1.0/if_let.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.0/if_let.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`if let` expressions"
flag = "if_let"
4 changes: 0 additions & 4 deletions data/1.0/macro_rules.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.0/macro_rules.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`macro_rules!`"
flag = "macro_rules"
4 changes: 0 additions & 4 deletions data/1.0/slicing_syntax.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.0/slicing_syntax.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`&foo[a..b]` as slicing syntax"
flag = "slicing_syntax"
4 changes: 0 additions & 4 deletions data/1.0/struct_variant.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.0/struct_variant.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "struct variants in enums"
flag = "struct_variant"
4 changes: 0 additions & 4 deletions data/1.0/tuple_indexing.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.0/tuple_indexing.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "tuple indexing"
flag = "tuple_indexing"
4 changes: 0 additions & 4 deletions data/1.0/while_let.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.0/while_let.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`while let` expressions"
flag = "while_let"
5 changes: 0 additions & 5 deletions data/1.1/split_whitespace.md

This file was deleted.

3 changes: 3 additions & 0 deletions data/1.1/split_whitespace.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title = "`str::split_whitespace`"
rfc_id = 1054
impl_pr_id = 24563
5 changes: 0 additions & 5 deletions data/1.10/cstr_default.md

This file was deleted.

3 changes: 3 additions & 0 deletions data/1.10/cstr_default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title = "`Default` implementation for `&CStr`"
flag = "cstr_default"
impl_pr_id = 32990
5 changes: 0 additions & 5 deletions data/1.10/cstring_default.md

This file was deleted.

3 changes: 3 additions & 0 deletions data/1.10/cstring_default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title = "`Default` implementation for `CString`"
flag = "cstr_default"
impl_pr_id = 32990
5 changes: 0 additions & 5 deletions data/1.10/weak_new.md

This file was deleted.

3 changes: 3 additions & 0 deletions data/1.10/weak_new.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title = "`sync::Weak::new`"
flag = "downgraded_weak"
impl_pr_id = 33699
4 changes: 0 additions & 4 deletions data/1.11/nested_cfg_attr.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.11/nested_cfg_attr.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "nested `cfg_attr` attributes"
impl_pr_id = 34216
4 changes: 0 additions & 4 deletions data/1.12/cfg_attr_path.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.12/cfg_attr_path.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`cfg_attr` on `path` attributes"
impl_pr_id = 34546
4 changes: 0 additions & 4 deletions data/1.12/nested_macro_rules.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.12/nested_macro_rules.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`macro_rules!` within `macro_rules!`"
impl_pr_id = 34925
6 changes: 0 additions & 6 deletions data/1.13/assert_ne.md

This file was deleted.

4 changes: 4 additions & 0 deletions data/1.13/assert_ne.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title = "`assert_ne!`"
rfc_id = 1653
impl_pr_id = 35074
tracking_issue_id = 35073
6 changes: 0 additions & 6 deletions data/1.13/debug_assert_ne.md

This file was deleted.

4 changes: 4 additions & 0 deletions data/1.13/debug_assert_ne.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title = "`debug_assert_ne!`"
rfc_id = 1653
impl_pr_id = 35074
tracking_issue_id = 35073
9 changes: 0 additions & 9 deletions data/1.13/question_mark.md

This file was deleted.

7 changes: 7 additions & 0 deletions data/1.13/question_mark.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title = "the `?` operator"
flag = "question_mark"
rfc_id = 243
impl_pr_id = 31954
tracking_issue_id = 31436
stabilization_pr_id = 36995
edition_guide_path = "rust-2018/error-handling-and-panics/the-question-mark-operator-for-easier-error-handling.html"
5 changes: 0 additions & 5 deletions data/1.13/type_macros.md

This file was deleted.

3 changes: 3 additions & 0 deletions data/1.13/type_macros.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title = "`macro_rules!` macros in type position"
flag = "type_macros"
tracking_issue_id = 27245
7 changes: 0 additions & 7 deletions data/1.14/dotdot_in_tuple_patterns.md

This file was deleted.

5 changes: 5 additions & 0 deletions data/1.14/dotdot_in_tuple_patterns.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
title = "`..` in tuple (struct) patterns"
flag = "dotdot_in_tuple_patterns"
rfc_id = 1492
tracking_issue_id = 33627
stabilization_pr_id = 36843
4 changes: 0 additions & 4 deletions data/1.14/fn_ptr_to_unsafe_fn_ptr.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.14/fn_ptr_to_unsafe_fn_ptr.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`fn` pointer to `unsafe fn` pointer coercion"
impl_pr_id = 37389
4 changes: 0 additions & 4 deletions data/1.14/println_no_args.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.14/println_no_args.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`println!` without arguments"
impl_pr_id = 36825
6 changes: 0 additions & 6 deletions data/1.15/proc_macro_derive.md

This file was deleted.

4 changes: 4 additions & 0 deletions data/1.15/proc_macro_derive.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title = "procedural derive macros (macros 1.1)"
flag = "proc_macro"
rfc_id = 1681
tracking_issue_id = 35900
5 changes: 0 additions & 5 deletions data/1.16/assoc_ty_struct_expr_pat.md

This file was deleted.

3 changes: 3 additions & 0 deletions data/1.16/assoc_ty_struct_expr_pat.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title = "associated types in struct expressions and patterns"
tracking_issue_id = 37544
stabilization_pr_id = 39282
5 changes: 0 additions & 5 deletions data/1.16/self_struct_expr_pat.md

This file was deleted.

3 changes: 3 additions & 0 deletions data/1.16/self_struct_expr_pat.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title = "`Self` in struct expressions and patterns"
tracking_issue_id = 37544
stabilization_pr_id = 39282
4 changes: 0 additions & 4 deletions data/1.16/writeln_no_args.md

This file was deleted.

2 changes: 2 additions & 0 deletions data/1.16/writeln_no_args.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = "`writeln!` without arguments"
impl_pr_id = 38469
6 changes: 0 additions & 6 deletions data/1.17/cell_non_copy.md

This file was deleted.

4 changes: 4 additions & 0 deletions data/1.17/cell_non_copy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title = "`Cell` with non-`Copy` types"
flag = "cell_non_copy"
rfc_id = 1651
impl_pr_id = 39793
8 changes: 0 additions & 8 deletions data/1.17/field_init_shorthand.md

This file was deleted.

6 changes: 6 additions & 0 deletions data/1.17/field_init_shorthand.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title = "field init shorthands (`x` for `x: x` in struct initializers)"
flag = "field_init_shorthand"
rfc_id = 1682
tracking_issue_id = 37340
stabilization_pr_id = 39761
edition_guide_path = "rust-2018/data-types/field-init-shorthand.html"
8 changes: 0 additions & 8 deletions data/1.17/static_in_const.md

This file was deleted.

6 changes: 6 additions & 0 deletions data/1.17/static_in_const.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title = "elision of `'static` lifetimes in `static`s and `const`s"
flag = "static_in_const"
rfc_id = 1623
tracking_issue_id = 35897
stabilization_pr_id = 39265
edition_guide_path = "rust-2018/ownership-and-lifetimes/simpler-lifetimes-in-static-and-const.html"
6 changes: 0 additions & 6 deletions data/1.17/static_recursion.md

This file was deleted.

4 changes: 4 additions & 0 deletions data/1.17/static_recursion.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title = "recursive static items"
flag = "static_recursion"
tracking_issue_id = 29719
stabilization_pr_id = 40027
5 changes: 0 additions & 5 deletions data/1.17/where_clauses_with_self.md

This file was deleted.

3 changes: 3 additions & 0 deletions data/1.17/where_clauses_with_self.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title = "`Self` in the where clause of trait impl's"
rfc_id = 1647
tracking_issue_id = 38864
13 changes: 0 additions & 13 deletions data/1.18/pub_restricted.md

This file was deleted.

Loading

0 comments on commit 1fc4439

Please sign in to comment.