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

Commit

Permalink
Merge branch 'master' into COMDOX-365-migration-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-matthews authored Dec 7, 2022
2 parents c13d140 + 294bb27 commit 1b8f8c8
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 10 deletions.
3 changes: 2 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ defaults:
scope:
path: mftf/v2
values:
guide_version: '2.3'
group: mftf-v2
github_files: https://github.com/magento/magento2-functional-testing-framework/tree/2.6.5/
github_repo: https://github.com/magento/magento2-functional-testing-framework/
Expand Down Expand Up @@ -206,7 +207,7 @@ algolia:
# It is safe to use in production front-end code.
# Used at src/_includes/layout/header-scripts.html
# For more details, refer to: https://www.algolia.com/doc/guides/security/api-keys/#search-only-api-key
search_only_key: d2d0f33ab73e291ef8d88d8b565e754c
search_only_key: d2d0f33ab73e291ef8d88d8b565e754c #gitleaks:allow

google:
gtm: GTM-KRCLXBB
Expand Down
51 changes: 44 additions & 7 deletions _plugins/generators/migrated_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
# Copyright © Adobe, Inc. All rights reserved.
# See COPYING.txt for license details.

# This plugin generates the page that contains a list of migrated topics.
# This plugin generates the page that contains a list of migrated topics: https://devdocs.magento.com/migrated.html
# Also, it adds global data:
# - site.data.migration.migrated_pages
# - site.data.migration.deprecated_pages
# - site.data.migration.all_migrating_pages
# - site.data.migration.remained_migrating_pages
#

module Jekyll
Expand All @@ -12,19 +17,27 @@ class MigratedLog < Generator
safe true

def generate(site)
# Make the site object available in any scope in this class.
@site = site
pages = @site.pages
migrated_pages = pages.filter { |page| page.data['layout'] and page.data['layout'].include? 'migrated' }
number_of_staying_pages = pages.count { |page| page.data['guide_version'] == '2.3' || page.data['group'].nil? }
migrated_pages = pages.select { |page| page.data['layout']&.include? 'migrated' }
v2_3_pages = pages.select { |page| page.data['guide_version'] == '2.3' }
remained_pages = pages - v2_3_pages
deprecated_pages = remained_pages.select { |page| page.data['group'].nil? || page.data['redirect_to'] }
all_migrating_pages = remained_pages - deprecated_pages
remained_migrating_pages = all_migrating_pages - migrated_pages
migrated_pages_data = []

# Create an array of JSON objects that contain metadata for migrated pages
migrated_pages.each do |page|
migrated_page = {
path: page.path,
title: page.data['title'] || abort("Error in '#{page.path}'.\n Check 'title' in the file's frontmatter.".red),
guide: page.data['layout'].include?('video') ? 'Video Tutorials' : @site.data.dig('toc', page.data['group'],
'label') || abort("Error in '#{page.path}'.\n Check 'group' in the file's frontmatter or 'label' in the corresponding TOC.".red),
guide: if page.data['layout'].include?('video')
'Video Tutorials'
else
@site.data.dig('toc', page.data['group'],
'label') || abort("Error in '#{page.path}'.\n Check 'group' in the file's frontmatter or 'label' in the corresponding TOC.".red)
end,
migrated_from: site.baseurl + page.url,
migrated_to: page.data['migrated_to'] || abort("Error in '#{page.path}'.\n Check 'migrated_to' in the file's frontmatter.".red),
migrated_to_source: if page.data['migrated_to'].start_with?('https://experienceleague.adobe.com')
Expand All @@ -38,8 +51,10 @@ def generate(site)
migrated_pages_data << migrated_page
end

# Group migrated pages by guide
migrated_pages_by_group = migrated_pages_data.group_by { |page| page[:guide] }.sort.to_h
content = "The folowing #{migrated_pages.size} topics out of #{pages.size - number_of_staying_pages} have been migrated and will be redirected soon.\n\n"
# Introductory text in the Migrated topics page
content = "The folowing #{migrated_pages.size} topics out of #{all_migrating_pages.size} have been migrated and will be redirected soon.\n\n"
migrated_pages_by_group.each do |guide, topics|
content += "\n## #{guide}\n\n\n"
topics.sort_by { |topic| topic[:title] }
Expand All @@ -48,6 +63,18 @@ def generate(site)
end
end

content += "\n***\n\n\n"
content += "\n## Pages to be migrated\n\n\n"

if remained_migrating_pages.empty?
content += 'All 2.4 and versionless pages were migrated'
else
remained_migrating_pages.sort_by(&:path)
.each do |page|
content += "1. `#{page.path}`\n"
end
end

# PageWithoutAFile handles processing files without reading it.
# 'migrated.md' is a virtual file that's been created during Jekyll run.
# See details in https://www.rubydoc.info/gems/jekyll/Jekyll/PageWithoutAFile
Expand All @@ -68,6 +95,16 @@ def generate(site)
# Add the newly constructed page object to the rest of pages
# on the site.
pages << topic

site.data['migration'] =
{
'migrated_pages' => migrated_pages.map(&:path),
'deprecated_pages' => deprecated_pages.map(&:path),
'all_migrating_pages' => all_migrating_pages.map(&:path),
'remained_migrating_pages' => remained_migrating_pages.map(&:path)
}

migrated_pages_data
end
end
end
6 changes: 5 additions & 1 deletion src/_data/main-nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@

- label: Functional Acceptance Testing (MFTF)
url: https://developer.adobe.com/commerce/testing/functional-testing-framework/
versionless: true
include_versions: ["2.4"]

- label: Functional Acceptance Testing (MFTF)
url: https://devdocs.magento.com/mftf/v2/docs/introduction.html
include_versions: ["2.3"]

- label: Integration Testing
url: https://developer.adobe.com/commerce/testing/guide/integration/
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
projects
<br></br>
Some content was consolidated or moved to different guides. If you can't find a topic, check the <a
href="https://devdocs.magento.com/migrated.html">Migrated topics</a> list for the new link.
href="{{site.baseurl}}/migrated.html">Migrated topics</a> list for the new link.
</header>
</section>

Expand Down
1 change: 1 addition & 0 deletions src/redoc/2.3/async-admin-rest-api.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
guide_version: 2.3
layout: redoc
specUrl: async-admin-schema.json
---
1 change: 1 addition & 0 deletions src/redoc/2.3/async-customer-rest-api.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
guide_version: 2.3
layout: redoc
specUrl: async-customer-schema.json
---
1 change: 1 addition & 0 deletions src/redoc/2.3/async-guest-rest-api.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
guide_version: 2.3
layout: redoc
specUrl: async-guest-schema.json
---

0 comments on commit 1b8f8c8

Please sign in to comment.