-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] add minor branding guidelines to
CONTRIBUTING.md
(#21495)
* Add minor branding guidelines. * Improve checks on branding style. * Prefer `lowercase` over `lower case`. https://english.stackexchange.com/a/59413 * Adequate existing docs to branding guidelines. * Improve lowercase checking algorithm to cover all wEiRD caSEs. * Improve wording. Co-authored-by: Aaron Brager <getaaron@gmail.com> * Refactor regex to take into account potential false positives. * Add unit tests for the tool name formatting tests. * Use full name for the variable. * Add missing test cases and fix typo in method. * Move test to actual specs. * Run rubocop. * Commit missing part. * Remove emoji indicators. * Remove emoji from specs too 😅 * Use File.readlines instead of File.read + split * Also detect formatting issues at start of line * Fix violations found by new implementation * Add the "features" word back to the table. --------- Co-authored-by: Aaron Brager <getaaron@gmail.com> Co-authored-by: Olivier Halligon <olivier@halligon.net>
- Loading branch information
1 parent
ab9fb32
commit 8c1fc73
Showing
17 changed files
with
143 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module Fastlane | ||
module Helper | ||
class ToolNameFormattingHelper | ||
attr_accessor :path, :is_documenting_invalid_examples | ||
|
||
# @param [String] path Path to the file to be checked for tool formatting | ||
# @param [Bool] is_documenting_invalid_examples | ||
# Ignore checks if line starts with "^\s*- ❌" (i.e. if it's a line that's already been marked as incorrect) | ||
# Typically used for files like `CONTRIBUTING.md`` (i.e. if it's the branding guidelines section) | ||
# | ||
def initialize(path:, is_documenting_invalid_examples: false) | ||
@path = path | ||
@is_documenting_invalid_examples = is_documenting_invalid_examples | ||
end | ||
|
||
def find_tool_name_formatting_errors | ||
errors = [] | ||
File.readlines(path, mode: 'rb:BOM|UTF-8').each_with_index do |line, index| | ||
line_number = index + 1 | ||
line.chomp! # Remove \n at end of line, to avoid including it in the error messages | ||
Fastlane::TOOLS.each do |tool| | ||
next if is_documenting_invalid_examples && line =~ /^\s*- ❌/ | ||
|
||
errors << "Use _#{tool}_ instead of `#{tool}` to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("`#{tool}`") | ||
errors << "Use _#{tool}_ instead of `_#{tool}_` to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("`_#{tool}_`") | ||
errors << "Use [_#{tool}_] instead of [#{tool}] to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("[#{tool}]") | ||
errors << "Use _#{tool}_ instead of **#{tool}** to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("**#{tool}**") | ||
errors << "Use <em>#{tool}<em> instead of <code>#{tool}</code> to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("<code>#{tool}</code>") | ||
errors << "Use <em>#{tool}<em> or _#{tool}_ instead of <ins>#{tool}</ins> to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("<ins>#{tool}</ins>") | ||
|
||
" #{line} ".scan(/([A-Z_]*)([_ `"])(#{Regexp.escape(tool.to_s)})\2([A-Z_]*)/i) do |prefix, delimiter, tool_name, suffix| | ||
is_lowercase = tool_name == tool.to_s.downcase | ||
looks_like_an_env_var = (tool_name == tool_name.upcase) && delimiter == '_' && (!prefix.empty? || !suffix.empty?) | ||
looks_like_ruby_module = line == "module #{tool_name}" | ||
is_valid_case = is_lowercase || looks_like_an_env_var || looks_like_ruby_module | ||
errors << "fastlane tools have to be formatted in lowercase: #{tool} in '#{path}:#{line_number}': #{line}" unless is_valid_case | ||
end | ||
end | ||
end | ||
errors | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Some lines in this file should start with a special formatting (the same used in CONTRIBUTING.md), so they are ignored by the name formatting checks. | ||
|
||
- ❌ "Use Fastlane to automate your screenshots." | ||
- ❌ "Use _Fastlane_ to automate your screenshots." | ||
- ❌ "Fastlane helps you deliver faster." | ||
- ❌ "Match makes code signing management easy." | ||
Use _fastlane_ to automate your screenshots. | ||
_fastlane_ helps you deliver faster. | ||
_match_ makes code signing management easy. | ||
- ❌ "`fastlane` is an all-in-one tool for app automation." | ||
- ❌ "**fastlane** is an all-in-one tool for app automation." | ||
- ❌ "fastlane is an all-in-one tool for app automation." | ||
- ❌ "<ins>fastlane</ins> is an all-in-one tool for app automation." | ||
- ❌ "`match` makes code signing management easy." | ||
_fastlane_ is an all-in-one tool for app automation. | ||
_match_ makes code signing management easy. | ||
FastLane makes code signing management easy. | ||
Fastlane makes code signing management easy. | ||
_FastLane_ makes code signing management easy. | ||
A sentence that has a tool name in the beginning of an env var: `MATCH_FILE` | ||
A sentence that has a tool name in the end of an env var: `UPDATE_FASTLANE` | ||
A sentence that has a tool name in the middle of an env var: `SOMETHING_FASTLANE_SOMETHING` | ||
A sentence that contains a _FastLane_ keyword, but also an env var: `FASTLANE_SKIP_CHANGELOG`. | ||
A sentence that contains `<PATH_TO_YOUR_LOCAL_FASTLANE_CLONE>` placeholder env var. | ||
A sentence that contains `File.expand_path("<PATH_TO_YOUR_LOCAL_FASTLANE_CLONE>")` placeholder string. | ||
A sentence that has a weird-looking env var with no prefix other than the delimiter: `_FASTLANE_SOMETHING` | ||
A sentence that has a weird-looking env var with no suffix other than the delimiter: `SOMETHING_FASTLANE_` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require_relative '../../helper/tool_name_formatting_helper.rb' | ||
|
||
describe Fastlane::Helper::ToolNameFormattingHelper do | ||
let(:fixture_path) { 'fastlane/spec/fixtures/fastfiles/tool_name_formatting.txt' } | ||
before(:each) do | ||
@helper = Fastlane::Helper::ToolNameFormattingHelper.new(path: fixture_path, is_documenting_invalid_examples: true) | ||
end | ||
|
||
describe 'when parsing fixture file' do | ||
it 'should match array of expected errors' do | ||
expected_errors = [ | ||
"fastlane tools have to be formatted in lowercase: fastlane in '#{fixture_path}:17': FastLane makes code signing management easy.", | ||
"fastlane tools have to be formatted in lowercase: fastlane in '#{fixture_path}:18': Fastlane makes code signing management easy.", | ||
"fastlane tools have to be formatted in lowercase: fastlane in '#{fixture_path}:19': _FastLane_ makes code signing management easy.", | ||
"fastlane tools have to be formatted in lowercase: fastlane in '#{fixture_path}:23': A sentence that contains a _FastLane_ keyword, but also an env var: `FASTLANE_SKIP_CHANGELOG`." | ||
] | ||
expect(@helper.find_tool_name_formatting_errors).to match_array(expected_errors) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Spaceship Documentation | ||
# _spaceship_ Documentation | ||
|
||
## API | ||
|
||
|