forked from telerik/ajax-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RakeFile and submodules script to handle fetching of resources …
…from external repositories.
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
task :xaml_docs do | ||
require "./helper_tools/submodules.rb" | ||
submodule = Submodule.new("xaml_docs", "./helper_tools/submodules.yml") | ||
submodule.init() | ||
submodule.update() | ||
submodule.map_folders() | ||
submodule.destroy() | ||
|
||
# replace all {% if site.site_name == 'WPF' %} | ||
# to {% if site.site_name == 'AJAX' %} | ||
|
||
original_regex = /{% if site.site_name == 'WPF' %}WPF|{% if site.site_name == 'WPF' %}/ | ||
original_string = "{% if site.site_name == 'WPF' %}" | ||
replacement = "{% if site.site_name == 'AJAX' %}" | ||
|
||
folders = submodule.get_target_folders() | ||
folders.each do |folder| | ||
files = Dir[folder + "**/*.md"] | ||
files.each do |file| | ||
content = File.read(file) | ||
if content.include?(original_string) | ||
#content = content.gsub(original, replacement) | ||
content = content.gsub(original_regex){ |match| | ||
match.end_with?("WPF") ? replacement + "AJAX" : replacement | ||
} | ||
File.write(file, content) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "yaml" | ||
require "fileutils" | ||
|
||
class Submodule | ||
def initialize(name, config_file) | ||
@name = name | ||
@config = YAML.load_file(config_file)[name] | ||
end | ||
|
||
def init | ||
system "git submodule add -f #{@config['remote_ssh']} #{@config['submodule_path']}" | ||
end | ||
|
||
def update | ||
system "git submodule update --remote -f #{@config['submodule_path']}" | ||
end | ||
|
||
def destroy | ||
system "git submodule deinit -f #{@config['submodule_path']}" | ||
system "git rm -f #{@config['submodule_path']}" | ||
if File.zero?(".gitmodules") | ||
system "git rm -f .gitmodules" | ||
end | ||
end | ||
|
||
def map_folders | ||
mappings = @config["mappings"] | ||
mappings.each do |map| | ||
FileUtils.rm_rf(map["target"]) | ||
FileUtils.cp_r(File.join(@config['submodule_path'], map["source"]), map["target"]) | ||
end | ||
end | ||
|
||
def get_target_folders | ||
target_folders = Array.new | ||
|
||
@config["mappings"].each do |map| | ||
target_folders.push(map["target"]) | ||
end | ||
|
||
return target_folders | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Configuration for the xaml_docs repo | ||
xaml_docs: | ||
remote_ssh: "[email protected]:telerik/xaml-docs.git" | ||
remote_ssl: "https://github.com/telerik/xaml-docs.git" | ||
submodule_path: "xaml_docs" | ||
mappings: [ | ||
{ target: "controls/wordsprocessing", source: "controls/radwordsprocessing/." }, | ||
{ target: "controls/pdfprocessing", source: "controls/radpdfprocessing/."}, | ||
{ target: "controls/ziplibrary", source: "controls/radziplibrary/."}, | ||
{ target: "controls/spreadprocessing", source: "controls/radspreadprocessing/."} | ||
] |