Skip to content

Commit

Permalink
Merge pull request #3797 from department-of-veterans-affairs/db/fetch…
Browse files Browse the repository at this point in the history
…-release-notes

What's new: Automate updating release notes
  • Loading branch information
danbrady authored Mar 4, 2025
2 parents 529cf4a + 35a5438 commit f15c998
Show file tree
Hide file tree
Showing 11 changed files with 5,350 additions and 444 deletions.
10 changes: 10 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,13 @@ exclude:
storybook_path: "http://localhost:8080"
storybook_prod_uswds_path: "https://design.va.gov/storybook/?path=/docs/uswds"
storybook_mobile_path: "https://department-of-veterans-affairs.github.io/va-mobile-library"

github_releases:
- name: site_releases
json: "https://api.github.com/repos/department-of-veterans-affairs/vets-design-system-documentation/releases"
- name: component_library_releases
json: "https://api.github.com/repos/department-of-veterans-affairs/component-library/releases"

figma_changelog_embed_url: https://embed.figma.com/proto/afurtw4iqQe6y4gXfNfkkk/VADS-Component-Library?page-id=14896%3A14785&node-id=14896-16876&viewport=550%2C221%2C1&scaling=contain&content-scaling=responsive&starting-point-node-id=14896%3A16876&embed-host=share&footer=false

figma_changelog_direct_url: https://embed.figma.com/design/afurtw4iqQe6y4gXfNfkkk/VADS-Component-Library?page-id=14896%3A14785&node-id=14896-16876&viewport=550%2C221%2C1&scaling=contain&content-scaling=responsive&starting-point-node-id=14896%3A16876&embed-host=share&footer=false
1,289 changes: 1,289 additions & 0 deletions json_data_cache/component_library_releases.json

Large diffs are not rendered by default.

3,867 changes: 3,867 additions & 0 deletions json_data_cache/site_releases.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"test": "echo \"Error: no test specified\" && exit 1",
"build": "gulp build",
"start": "yarn run build && bundle exec jekyll serve --baseurl ''",
"watch": "yarn run build && bundle exec jekyll serve --baseurl '' --incremental"
"watch": "yarn run build && bundle exec jekyll serve --baseurl '' --incremental",
"update-releases": "rm -rf json_data_cache && yarn run build && bundle exec jekyll serve --baseurl ''"
},
"repository": {
"type": "git",
Expand Down
466 changes: 24 additions & 442 deletions src/_about/whats-new.md

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions src/_includes/_github_markdown_parser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{% comment %}
Capture linebreaks before headings (to add another linebreak which fixes an issue where the headings are incorrectly nested within a list)
{% endcomment %}
{% assign reLineBreakBeforeHeader = '(\r\n)#' %}

{% comment %}
Capture github URL (to convert to markdown-type link)
{% endcomment %}
{% assign reGithubUrl = '(https?:\/\/(www\.)?github\.com(?:\/.*)?)' %}

{% comment %}
Capture any issue numbers in titles (to make them links)
{% endcomment %}
{% assign reIssueNumbersInTitle = '(#(\d+))' %}

{% comment %}
Capture PR number from URL (to create a link to the PR)
{% endcomment %}
{% assign rePrUrl = '\[https?:\/\/(www\.)?github\.com(?:\/.*)?pull\/(\d+)\s?\]' %}

{% comment %}
Capture h2-h5 headings (to +1 heading level so the HTML stays semantically structured with our page)
{% endcomment %}
{% assign reHeadingLevels = '(#{2,6})\s' %}

{% comment %}
Capture github usernames (to make a link to user profile)
{% endcomment %}
{% assign reUsernames = 'by\s(@(\S+))\s' %}

{% comment %}
Trim number of releases to show
{% endcomment %}
{% assign recentReleases = include.json | slice: 0, include.num_recent_releases %}

{% for release in recentReleases %}
<va-card class="vads-u-margin-bottom--2">
<span class="usa-label">{{ release.name }}</span>
<div class="vads-u-font-size--xl vads-u-font-weight--bold vads-u-font-family--serif">{{ release.published_at | date: "%B %-d, %Y" }}</div>
{{ release.body
| regexreplace: reLineBreakBeforeHeader, '\1\1#'
| regexreplace: reGithubUrl, '[\1](\1)'
| regexreplace: reIssueNumbersInTitle, '[\1](https:/github.com/department-of-veterans-affairs/vets-design-system-documentation/issues/\2)'
| regexreplace: rePrUrl, '[\#\2]'
| regexreplace: reHeadingLevels, '\1# '
| regexreplace: reUsernames, 'by [\1](https://github.com/\2) '
| markdownify
}}
</va-card>
{% endfor %}
3 changes: 2 additions & 1 deletion src/_includes/_site-on-this-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
</dt>
{% for item in page.anchors %}
<dd role="definition" class="site-on-this-page__definition">
<a class="site-on-this-page__link" href="#{{ item.anchor | downcase | replace: " ", "-" | replace: "’", "" | replace: "'", "" | replace: ",", "" }}">
<a class="site-on-this-page__link" href="#{{ item.anchor | downcase | replace: " ", "-" | replace: "’" , "" |
replace: "'" , "" | replace: "," , "" | replace: "." , "" }}">
<i aria-hidden="true" class="fas fa-arrow-down"></i>
{{ item.anchor }}
</a>
Expand Down
12 changes: 12 additions & 0 deletions src/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
</div>
</div>
</main>
{% elsif page.sidebar %}
{% include _site-content-nav.html %}
<div class="site-content__content">
<main id="main-content" class="site-l-content-wrapper--sidebar large-screen:vads-u-margin-top--neg2">
<aside class="main-content__sidebar">
{% include _site-on-this-page.html %}
</aside>
<div class="main-content__content">
{{ content }}
</div>
</main>
</div>
{% else %}
{% include _site-content-nav.html %}
<div class="site-content__content">
Expand Down
57 changes: 57 additions & 0 deletions src/_plugins/jekyll_get_json.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'json'
require 'open-uri'

module Jekyll_Get_Json
class Generator < Jekyll::Generator
safe true
priority :highest

def get_final_url(url)
if url.start_with? "https://api.github.com/"
access_token = ENV['GITHUB_ACCESS_TOKEN']
if access_token
return "#{url}?access_token=#{access_token}"
end
end
url
end

def load_json(site, feed)
name = feed['name']
url = feed['json']
path = "json_data_cache/#{name}.json"
if not File.exist?(path)
FileUtils.mkpath File.dirname(path)
print "* Caching #{url}\n".green
print " in "
print "#{path}\n".cyan
githubJekyllCache = URI(get_final_url(url)).open
data = JSON.load(githubJekyllCache)
File.open(path, 'wb') do |file|
file << JSON.pretty_generate(data)
end
end
cacheJSON = File.open(path)
site.data[name] = JSON.load(cacheJSON)
end

def generate(site)
config = site.config['github_releases']
if !config
return
end
if !config.kind_of?(Array)
config = [config]
end
config.each do |feed|
url = feed['json']
begin
load_json(site, feed)
rescue => e
print "jekyll_get: error fetching #{url}: #{e}\n".red
next
end
end
end
end
end
10 changes: 10 additions & 0 deletions src/_plugins/vads.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'uri'

module VADS

def regexreplace(input, regex, replacement = '')
input.to_s.gsub(Regexp.new(regex), replacement.to_s)
end
end

Liquid::Template.register_filter(VADS)
27 changes: 27 additions & 0 deletions src/assets/stylesheets/_layout/_content-wrappers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,31 @@
letter-spacing: -0.2em;
content: '\00a0';
}
}

.site-l-content-wrapper--sidebar {
display: flex;
gap: units(8);

.main-content__content {
flex: 1;
order: 1
}

.main-content__sidebar {
display: none;

@include media($large-screen) {
display: inline;
flex-basis: 256px;
order: 2;
}
}

.site-on-this-page {
border-left: 1px solid var(--vads-color-base-lighter);
position: sticky;
padding: units(2) 0 units(2) units(3);
top: units(10);
}
}

0 comments on commit f15c998

Please sign in to comment.