diff --git a/test/test_helper.rb b/test/test_helper.rb index 1911b181321b..90b8029ef6cd 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -45,3 +45,13 @@ def metadata_for(topic) flunk "invalid YAML: #{ex.message}" end end + +def text_for(topic) + path = File.join(topics_dir, topic, "index.md") + return "" unless File.file?(path) + + parts = File.read(path).split("---", 3) + return "" unless parts.size >= 2 + + parts[2] +end diff --git a/test/topics_test.rb b/test/topics_test.rb index 107a6e566a1e..5908d2e69a10 100644 --- a/test/topics_test.rb +++ b/test/topics_test.rb @@ -58,6 +58,56 @@ assert metadata.key?(key), "expected to have '#{key}' defined for topic" assert metadata[key] && metadata[key].strip.size > 0, "expected to have a value for '#{key}'" + end + + it "follows the Topic Page Style Guide" do + text = text_for(topic) + end_punctuation = %w[. , ; :] + text.lines do |line| + line.chomp! + + refute_includes line, "&", 'Use "and" rather than an ampersand' + refute_includes line, "!", "Avoid exclamation points in topic pages" + refute_includes line, "open-source", + "Use open source without a hyphen" + + %w[Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec].each do |month| + refute_includes line, "#{month} ", "Include and spell out the month" + end + + %w[1st 2nd 3rd 1th 2th 3th 4th 5th 6th 7th 8th 9th].each do |date_end| + refute_includes line, date_end, + 'Include the day number without the "th" or "nd" at the end' + end + + %w[GitHubbing Gitting].each do |no_git_verb| + refute_includes line, no_git_verb, + "Never use “GitHub” or “Git” as a verb." + end + + %w[Github github].each do |wrong_github| + refute_includes line, wrong_github, + 'Always use correct capitalization when referring to "GitHub"' + end + + (end_punctuation + [" "]).each do |punctuation| + refute_includes line, "git#{punctuation}", + 'Always use correct capitalization when referring to "Git"' + + (1..10).each do |digit| + refute_includes line, " #{digit}#{punctuation}", + 'Write out "one" and every number less than 10' + end + end + end + text.delete("\n").split(".").each do |sentence| + # This is arbitrary; 2 is more correct but 3 avoids false positives. + next if sentence.count(",") < 3 + + %w[and or].each do |conjunction| + next unless sentence.include? " #{conjunction} " + assert_includes sentence, ", #{conjunction}", "Always use the Oxford comma" + end end end end diff --git a/topics/csharp/index.md b/topics/csharp/index.md index 8ad07fc78d67..04573f3c1962 100644 --- a/topics/csharp/index.md +++ b/topics/csharp/index.md @@ -9,4 +9,4 @@ topic: csharp url: https://docs.microsoft.com/en-us/dotnet/csharp/csharp wikipedia_url: https://en.wikipedia.org/wiki/C_Sharp_(programming_language) --- -C# is a programming language used for web development. It is a hybrid of C & C++ that functions similar to Java and is meant for Microsoft's .NET framework. +C# is a programming language used for web development. It is a hybrid of C and C++ that functions similar to Java and is meant for Microsoft's .NET framework. diff --git a/topics/database/index.md b/topics/database/index.md index b72448864cba..2a56dc0ad725 100644 --- a/topics/database/index.md +++ b/topics/database/index.md @@ -6,4 +6,4 @@ short_description: A database is a structured set of data held in a computer, us topic: database wikipedia_url: https://en.wikipedia.org/wiki/Database --- -A database is a structured set of data held in a computer, most often a server. Databases use a database management system (DBMS) that interacts with users, similar to a lookup table. Modern databases are designed to allow for creation, querying, updating and administration of the data it holds. +A database is a structured set of data held in a computer, most often a server. Databases use a database management system (DBMS) that interacts with users, similar to a lookup table. Modern databases are designed to allow for creation, querying, updating, and administration of the data it holds. diff --git a/topics/gulp/index.md b/topics/gulp/index.md index f1e30c9d9fdb..79c5f9cbe306 100644 --- a/topics/gulp/index.md +++ b/topics/gulp/index.md @@ -10,4 +10,4 @@ topic: gulp url: http://gulpjs.com/ wikipedia_url: https://en.wikipedia.org/wiki/Gulp.js --- -Gulp is an open source toolkit built on Node.js & npm. It is used for automating and streamlining repetitive tasks in front-end web development. +Gulp is an open source toolkit built on Node.js and npm. It is used for automating and streamlining repetitive tasks in front-end web development. diff --git a/topics/ios/index.md b/topics/ios/index.md index 7dcd8b95154b..ea558eb6a4f0 100644 --- a/topics/ios/index.md +++ b/topics/ios/index.md @@ -9,4 +9,4 @@ topic: ios url: https://www.apple.com/ios/ wikipedia_url: https://en.wikipedia.org/wiki/IOS --- -iOS is the operating system for all of Apple’s mobile products. The operating system was unveiled at Macworld Conference & Expo in 2007 to support the company’s new venture, the iPhone. Since then, the operating system has grown to incorporate other products, including the iPad and iPod Touch. +iOS is the operating system for all of Apple’s mobile products. The operating system was unveiled at Macworld Conference and Expo in 2007 to support the company’s new venture, the iPhone. Since then, the operating system has grown to incorporate other products, including the iPad and iPod Touch. diff --git a/topics/mysql/index.md b/topics/mysql/index.md index 8c314e96fc44..1c14e6e38899 100644 --- a/topics/mysql/index.md +++ b/topics/mysql/index.md @@ -10,4 +10,4 @@ topic: mysql url: https://www.mysql.com/ wikipedia_url: https://en.wikipedia.org/wiki/MySQL --- -MySQL is an open source relational database management system. Based in Structured Query Language (SQL), MySQL can run on most platforms and is mainly used for web-based applications. It is written in C & C++. +MySQL is an open source relational database management system. Based in Structured Query Language (SQL), MySQL can run on most platforms and is mainly used for web-based applications. It is written in C and C++. diff --git a/topics/react-native/index.md b/topics/react-native/index.md index b2061deab5dd..4f5e840464e0 100644 --- a/topics/react-native/index.md +++ b/topics/react-native/index.md @@ -10,4 +10,4 @@ topic: react-native url: http://reactnative.com/ wikipedia_url: https://en.wikipedia.org/wiki/React_(JavaScript_library)#React_Native --- -React Native is a JavaScript mobile framework developed by Facebook. It allows developers to build Android & iOS mobile apps using JavaScript and reuse code across web & mobile applications. +React Native is a JavaScript mobile framework developed by Facebook. It allows developers to build Android and iOS mobile apps using JavaScript and reuse code across web and mobile applications. diff --git a/topics/redux/index.md b/topics/redux/index.md index f73ebe9e1518..8d902d96dde1 100644 --- a/topics/redux/index.md +++ b/topics/redux/index.md @@ -9,4 +9,4 @@ topic: redux url: http://redux.js.org/ wikipedia_url: https://en.wikipedia.org/wiki/Redux_(JavaScript_library) --- -Redux is an open-source JavaScript library, designed to allow for state management of JavaScript applications. Inspired by Elm, Redux is a debugging tool and supports robust application data-flow architecture. Redux is frequently used in combination with React. +Redux is an open source JavaScript library, designed to allow for state management of JavaScript applications. Inspired by Elm, Redux is a debugging tool and supports robust application data-flow architecture. Redux is frequently used in combination with React.