Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Implement Docfile
Browse files Browse the repository at this point in the history
Add Docfile that contatins configuration for devdocs content management
Implement rake automation to use the Docfile locally and on CICD
  • Loading branch information
dshevtsov committed Apr 15, 2019
1 parent 2856d6f commit b2880cd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Docfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The "guides/v2.0" directory contains all content from the "2.0" branch of the "magento/devdocs" repository.
The "guides/m1x" directory contains all content from the "master" branch of the "magento/devdocs-m1" repository.
The "mbi" directory contains only "docs" content from the "master" branch of the "magento/devdocs-mbi" repository.
The "page-builder" directory contains only "docs" content from the "develop" branch of the "magento-devdocs/magento2-page-builder" repository.
The "mftf" directory contains only "docs" content from the "develop" branch of the "magento/magento2-functional-testing-framework" repository.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require 'colorator'
require_relative 'rakelib/lib/link-checker.rb'
require_relative 'rakelib/lib/converter.rb'
require_relative 'rakelib/lib/double-slash-check.rb'
require_relative 'rakelib/lib/doc-config.rb'

desc "Same as 'rake', 'rake preview'"
task default: %w[preview]
Expand Down
21 changes: 21 additions & 0 deletions rakelib/lib/doc-config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Read Docfile file and get configuration data for adding subrepositories
class DocConfig
attr_reader :config
def initialize(config_file = 'Docfile')
@config_data = File.readlines(config_file)
@config = []
parse_file
end

def parse_file
@config =
@config_data.map do |string|
{
'directory' => string[/(?<=")[^"]+(?="\sdirectory)/],
'repository' => string[/(?<=")[^"]+(?="\srepository)/],
'branch' => string[/(?<=")[^"]+(?="\sbranch)/],
'filter' => string.match?(/(?<=")[^"]+(?="\scontent)/)
}
end
end
end
21 changes: 13 additions & 8 deletions rakelib/multirepo.rake
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
namespace :multirepo do
desc 'Add content from external repositories'
desc 'Create a file tree for devdocs website and get all required content'
task :init do
sh './scripts/docs-from-code.sh mbi git@github.com:magento/devdocs-mbi.git master'
sh './scripts/docs-from-code.sh page-builder git@github.com:magento-devdocs/magento2-page-builder.git develop'
sh './scripts/docs-from-code.sh mftf git@github.com:magento/magento2-functional-testing-framework.git develop'
ssh = 'git@github.com:'
https = 'https://${token}@github.com/'
protocol =
if ENV['token']
https
else
ssh
end

# The last argument 'false' disables content filtering by sparse checkout.
# It covers cases when we need entire repository, not only the '/docs/' directory.
sh './scripts/docs-from-code.sh guides/m1x git@github.com:magento/devdocs-m1.git master false'
sh './scripts/docs-from-code.sh guides/v2.0 git@github.com:magento/devdocs.git 2.0 false'
config = DocConfig.new.config
config.each do |subrepo|
sh "./scripts/docs-from-code.sh #{subrepo['directory']} #{protocol}#{subrepo['repository']}.git #{subrepo['branch']} #{subrepo['filter']}"
end
end

desc 'Add multirepo docs providing shell arguments "dir=<directory where to init a repo>", "repo=<SSH URL>", "branch=<branch to checkout>", "filter=<true/false>" ("true" by default) to 1) filter content if "true" or 2) add content from the entire repository if "false".'
Expand Down

0 comments on commit b2880cd

Please sign in to comment.