From 5315934d888797432d62ec4a55303aeacb8cd286 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 3 Jun 2020 18:22:05 +0200 Subject: Don't store generated docs in the repo --- xtask/src/codegen.rs | 6 ++++-- xtask/src/codegen/gen_assists_docs.rs | 11 ++++++----- xtask/src/lib.rs | 2 ++ xtask/src/main.rs | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 5511c01d5..f5f4b964a 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -18,8 +18,10 @@ use std::{ use crate::{not_bash::fs2, project_root, Result}; pub use self::{ - gen_assists_docs::generate_assists_docs, gen_feature_docs::generate_feature_docs, - gen_parser_tests::generate_parser_tests, gen_syntax::generate_syntax, + gen_assists_docs::{generate_assists_docs, generate_assists_tests}, + gen_feature_docs::generate_feature_docs, + gen_parser_tests::generate_parser_tests, + gen_syntax::generate_syntax, }; const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 6c1be5350..526941f73 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs @@ -7,16 +7,17 @@ use crate::{ project_root, rust_files, Result, }; -pub fn generate_assists_docs(mode: Mode) -> Result<()> { +pub fn generate_assists_tests(mode: Mode) -> Result<()> { let assists = Assist::collect()?; - generate_tests(&assists, mode)?; + generate_tests(&assists, mode) +} +pub fn generate_assists_docs(mode: Mode) -> Result<()> { + let assists = Assist::collect()?; let contents = assists.into_iter().map(|it| it.to_string()).collect::>().join("\n\n"); let contents = contents.trim().to_string() + "\n"; let dst = project_root().join("docs/user/generated_assists.adoc"); - codegen::update(&dst, &contents, mode)?; - - Ok(()) + codegen::update(&dst, &contents, mode) } #[derive(Debug)] diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 874957885..739f49f7b 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -160,6 +160,8 @@ pub fn run_release(dry_run: bool) -> Result<()> { run!("git reset --hard tags/nightly")?; run!("git push")?; } + codegen::generate_assists_docs(Mode::Overwrite)?; + codegen::generate_feature_docs(Mode::Overwrite)?; let website_root = project_root().join("../rust-analyzer.github.io"); let changelog_dir = website_root.join("./thisweek/_posts"); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 9d7cdd114..81bb3a33f 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -74,6 +74,7 @@ FLAGS: args.finish()?; codegen::generate_syntax(Mode::Overwrite)?; codegen::generate_parser_tests(Mode::Overwrite)?; + codegen::generate_assists_tests(Mode::Overwrite)?; codegen::generate_assists_docs(Mode::Overwrite)?; codegen::generate_feature_docs(Mode::Overwrite)?; Ok(()) -- cgit v1.2.3 From 97ea2dfc4b6b49a175d4d0f85b37c77bd1ea3f3b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 8 Jun 2020 13:58:54 +0200 Subject: Move to a dedicated file --- xtask/src/lib.rs | 57 ++------------------------------------------------ xtask/src/main.rs | 5 +++-- xtask/src/release.rs | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 57 deletions(-) create mode 100644 xtask/src/release.rs (limited to 'xtask/src') diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 739f49f7b..747654c1f 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -4,6 +4,7 @@ pub mod not_bash; pub mod install; +pub mod release; pub mod dist; pub mod pre_commit; @@ -19,7 +20,7 @@ use walkdir::{DirEntry, WalkDir}; use crate::{ codegen::Mode, - not_bash::{date_iso, fs2, pushd, pushenv, rm_rf, run}, + not_bash::{fs2, pushd, pushenv, rm_rf, run}, }; pub use anyhow::{bail, Context as _, Result}; @@ -153,60 +154,6 @@ pub fn run_pre_cache() -> Result<()> { Ok(()) } -pub fn run_release(dry_run: bool) -> Result<()> { - if !dry_run { - run!("git switch release")?; - run!("git fetch upstream --tags --force")?; - run!("git reset --hard tags/nightly")?; - run!("git push")?; - } - codegen::generate_assists_docs(Mode::Overwrite)?; - codegen::generate_feature_docs(Mode::Overwrite)?; - - let website_root = project_root().join("../rust-analyzer.github.io"); - let changelog_dir = website_root.join("./thisweek/_posts"); - - let today = date_iso()?; - let commit = run!("git rev-parse HEAD")?; - let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); - - let contents = format!( - "\ -= Changelog #{} -:sectanchors: -:page-layout: post - -Commit: commit:{}[] + -Release: release:{}[] - -== New Features - -* pr:[] . - -== Fixes - -== Internal Improvements -", - changelog_n, commit, today - ); - - let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); - fs2::write(&path, &contents)?; - - for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { - let src = project_root().join("./docs/user/").join(adoc); - let dst = website_root.join(adoc); - fs2::copy(src, dst)?; - } - - let tags = run!("git tag --list"; echo = false)?; - let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); - - println!("\n git log {}..HEAD --merges --reverse", prev_tag); - - Ok(()) -} - fn is_release_tag(tag: &str) -> bool { tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 81bb3a33f..701c60fc0 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -16,8 +16,9 @@ use xtask::{ dist::run_dist, install::{ClientOpt, InstallCmd, ServerOpt}, not_bash::pushd, - pre_commit, project_root, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, - Result, + pre_commit, project_root, + release::run_release, + run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result, }; fn main() -> Result<()> { diff --git a/xtask/src/release.rs b/xtask/src/release.rs new file mode 100644 index 000000000..771a8cf71 --- /dev/null +++ b/xtask/src/release.rs @@ -0,0 +1,59 @@ +use crate::{ + codegen, is_release_tag, + not_bash::{date_iso, fs2, run}, + project_root, Mode, Result, +}; + +pub fn run_release(dry_run: bool) -> Result<()> { + if !dry_run { + run!("git switch release")?; + run!("git fetch upstream --tags --force")?; + run!("git reset --hard tags/nightly")?; + run!("git push")?; + } + codegen::generate_assists_docs(Mode::Overwrite)?; + codegen::generate_feature_docs(Mode::Overwrite)?; + + let website_root = project_root().join("../rust-analyzer.github.io"); + let changelog_dir = website_root.join("./thisweek/_posts"); + + let today = date_iso()?; + let commit = run!("git rev-parse HEAD")?; + let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); + + let contents = format!( + "\ += Changelog #{} +:sectanchors: +:page-layout: post + +Commit: commit:{}[] + +Release: release:{}[] + +== New Features + +* pr:[] . + +== Fixes + +== Internal Improvements +", + changelog_n, commit, today + ); + + let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); + fs2::write(&path, &contents)?; + + for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { + let src = project_root().join("./docs/user/").join(adoc); + let dst = website_root.join(adoc); + fs2::copy(src, dst)?; + } + + let tags = run!("git tag --list"; echo = false)?; + let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); + + println!("\n git log {}..HEAD --merges --reverse", prev_tag); + + Ok(()) +} -- cgit v1.2.3 From cbc5eb87386e132c63ec33ff496019fad7478fe8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 8 Jun 2020 14:00:30 +0200 Subject: Refactor --- xtask/src/main.rs | 4 +-- xtask/src/release.rs | 86 ++++++++++++++++++++++++++++------------------------ 2 files changed, 49 insertions(+), 41 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 701c60fc0..f7a79362d 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -17,7 +17,7 @@ use xtask::{ install::{ClientOpt, InstallCmd, ServerOpt}, not_bash::pushd, pre_commit, project_root, - release::run_release, + release::ReleaseCmd, run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result, }; @@ -103,7 +103,7 @@ FLAGS: "release" => { let dry_run = args.contains("--dry-run"); args.finish()?; - run_release(dry_run) + ReleaseCmd { dry_run }.run() } "dist" => { let nightly = args.contains("--nightly"); diff --git a/xtask/src/release.rs b/xtask/src/release.rs index 771a8cf71..36c912184 100644 --- a/xtask/src/release.rs +++ b/xtask/src/release.rs @@ -4,56 +4,64 @@ use crate::{ project_root, Mode, Result, }; -pub fn run_release(dry_run: bool) -> Result<()> { - if !dry_run { - run!("git switch release")?; - run!("git fetch upstream --tags --force")?; - run!("git reset --hard tags/nightly")?; - run!("git push")?; - } - codegen::generate_assists_docs(Mode::Overwrite)?; - codegen::generate_feature_docs(Mode::Overwrite)?; +pub struct ReleaseCmd { + pub dry_run: bool, +} - let website_root = project_root().join("../rust-analyzer.github.io"); - let changelog_dir = website_root.join("./thisweek/_posts"); +impl ReleaseCmd { + pub fn run(self) -> Result<()> { + if !self.dry_run { + run!("git switch release")?; + run!("git fetch upstream --tags --force")?; + run!("git reset --hard tags/nightly")?; + run!("git push")?; + } + codegen::generate_assists_docs(Mode::Overwrite)?; + codegen::generate_feature_docs(Mode::Overwrite)?; - let today = date_iso()?; - let commit = run!("git rev-parse HEAD")?; - let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); + let website_root = project_root().join("../rust-analyzer.github.io"); + let changelog_dir = website_root.join("./thisweek/_posts"); - let contents = format!( - "\ -= Changelog #{} -:sectanchors: -:page-layout: post + let today = date_iso()?; + let commit = run!("git rev-parse HEAD")?; + let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); -Commit: commit:{}[] + -Release: release:{}[] + let contents = format!( + "\ + = Changelog #{} + :sectanchors: + :page-layout: post -== New Features + Commit: commit:{}[] + + Release: release:{}[] -* pr:[] . + == New Features -== Fixes + * pr:[] . -== Internal Improvements -", - changelog_n, commit, today - ); + == Fixes - let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); - fs2::write(&path, &contents)?; + == Internal Improvements + ", + changelog_n, commit, today + ); - for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { - let src = project_root().join("./docs/user/").join(adoc); - let dst = website_root.join(adoc); - fs2::copy(src, dst)?; - } + let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); + fs2::write(&path, &contents)?; - let tags = run!("git tag --list"; echo = false)?; - let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); + for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { + let src = project_root().join("./docs/user/").join(adoc); + let dst = website_root.join(adoc); + fs2::copy(src, dst)?; + } - println!("\n git log {}..HEAD --merges --reverse", prev_tag); + let tags = run!("git tag --list"; echo = false)?; + let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); - Ok(()) + let git_log = run!("git log {}..HEAD --merges --reverse", prev_tag; echo = false)?; + let git_log_dst = website_root.join("git.log"); + fs2::write(git_log_dst, &git_log)?; + + Ok(()) + } } -- cgit v1.2.3 From 506e1ddbfa5213f254923da9bbf0efddc6f1fc34 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Wed, 10 Jun 2020 11:30:48 +0100 Subject: Separating parsing of `for` in predicates and types --- xtask/src/ast_src.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xtask/src') diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index f60f0fb16..392648d71 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs @@ -1707,7 +1707,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { /// ``` /// /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses) - struct WherePred: TypeBoundsOwner { T![lifetime], TypeRef } + struct WherePred: TypeBoundsOwner { T![for], TypeParamList, T![lifetime], TypeRef } /// Where clause. /// -- cgit v1.2.3 From 33e009ec4258e058b966134cd251fd17b390d7f5 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 12 Jun 2020 01:23:04 +0300 Subject: Use more idiomatic style for lifetimes in generated code --- xtask/src/codegen/gen_syntax.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 19d5594f5..e66304c01 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -40,7 +40,7 @@ fn generate_tokens(grammar: AstSrc<'_>) -> Result { pub(crate) syntax: SyntaxToken, } impl std::fmt::Display for #name { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(&self.syntax, f) } } @@ -199,7 +199,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result { enum_names.chain(node_names.clone()).map(|it| format_ident!("{}", it)).map(|name| { quote! { impl std::fmt::Display for #name { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -- cgit v1.2.3 From 4fefc7d06c8da093e783852c5f0d3aea31e2c939 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 12 Jun 2020 02:06:28 +0300 Subject: Simplify --- xtask/src/codegen/gen_syntax.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xtask/src') diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 19d5594f5..f8b34638b 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -68,7 +68,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result { .iter() .map(|node| { let name = format_ident!("{}", node.name); - let kind = format_ident!("{}", to_upper_snake_case(&name.to_string())); + let kind = format_ident!("{}", to_upper_snake_case(node.name)); let traits = node.traits.iter().map(|trait_name| { let trait_name = format_ident!("{}", trait_name); quote!(impl ast::#trait_name for #name {}) -- cgit v1.2.3