1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use direction instead of rtl flag.

Improve readability by using `direction` as CSS does.

More info: https://developer.mozilla.org/en-US/docs/Web/CSS/direction
Continues: #34486

[Alberto Almagro + Ufuk Kayserilioglu]
This commit is contained in:
Alberto Almagro 2018-11-22 20:48:25 +01:00
parent 1b68ead8f8
commit 5020c2e302
2 changed files with 21 additions and 18 deletions

View file

@ -20,11 +20,11 @@ version = env_value["RAILS_VERSION"]
edge = `git rev-parse HEAD`.strip unless version
RailsGuides::Generator.new(
edge: edge,
version: version,
all: env_flag["ALL"],
only: env_value["ONLY"],
kindle: env_flag["KINDLE"],
language: env_value["GUIDES_LANGUAGE"],
rtl: env_value["RTL"]
edge: edge,
version: version,
all: env_flag["ALL"],
only: env_value["ONLY"],
kindle: env_flag["KINDLE"],
language: env_value["GUIDES_LANGUAGE"],
direction: env_value["DIRECTION"].to_sym
).generate

View file

@ -17,14 +17,14 @@ module RailsGuides
class Generator
GUIDES_RE = /\.(?:erb|md)\z/
def initialize(edge:, version:, all:, only:, kindle:, language:, rtl: false)
@edge = edge
@version = version
@all = all
@only = only
@kindle = kindle
@language = language
@rtl = rtl
def initialize(edge:, version:, all:, only:, kindle:, language:, direction: :ltr)
@edge = edge
@version = version
@all = all
@only = only
@kindle = kindle
@language = language
@direction = direction
if @kindle
check_for_kindlegen
@ -118,12 +118,15 @@ module RailsGuides
def copy_assets
FileUtils.cp_r(Dir.glob("#{@guides_dir}/assets/*"), @output_dir)
if @rtl
FileUtils.rm(Dir.glob("#{@output_dir}/stylesheets/main.css"))
FileUtils.mv("#{@output_dir}/stylesheets/main.rtl.css", "#{@output_dir}/stylesheets/main.css")
if @direction == :rtl
overwrite_css_with_right_to_left_direction
end
end
def overwrite_css_with_right_to_left_direction
FileUtils.mv("#{@output_dir}/stylesheets/main.rtl.css", "#{@output_dir}/stylesheets/main.css")
end
def output_file_for(guide)
if guide.end_with?(".md")
guide.sub(/md\z/, "html")