Skip to content

Commit

Permalink
Merge pull request #416 from Orange-OpenSource/258-documentation-vers…
Browse files Browse the repository at this point in the history
…ioning

258 - documentation versioning
  • Loading branch information
paulinea authored Jan 31, 2023
2 parents a607cd9 + 17dd80d commit 0389821
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* /
*/

import com.orange.ods.gradle.execute
plugins {
id("release")
}

buildscript {
repositories {
Expand Down Expand Up @@ -37,11 +39,3 @@ tasks.register<Delete>("clean") {
group = "cleanup"
delete(rootProject.buildDir)
}

tasks.register<DefaultTask>("tagRelease") {
doLast {
val tag = version.toString()
execute("git", "tag", tag)
execute("git", "push", "origin", tag)
}
}
81 changes: 81 additions & 0 deletions buildSrc/src/main/kotlin/release.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
*
* Copyright 2021 Orange
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* /
*/

import com.orange.ods.gradle.execute
import java.text.SimpleDateFormat
import java.util.*

tasks.register<DefaultTask>("prepareRelease") {
doLast {
val newVersion = project.gradle.startParameter.projectProperties["version"]
if (newVersion == null) {
throw GradleException("Please set the \"version\" project property.")
}

updateVersion(newVersion)
updateDependencies(newVersion)
updateChangelog(newVersion)
archiveDocumentation(newVersion)
}
}

tasks.register<DefaultTask>("tagRelease") {
doLast {
val tag = version.toString()
execute("git", "tag", tag)
execute("git", "push", "origin", tag)
}
}

fun updateVersion(version: String) {
execute("sed", "-Ei", "", "s/^(version=).*/\\1$version/", "gradle.properties")
}

fun updateDependencies(version: String) {
val substituteDependencyArg = "s/(com\\.orange\\.ods\\.android:ods-[^:]*:)[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+/\\1$version/"
execute("sed", "-Ei", "", substituteDependencyArg, "docs/home_content.md")
execute("sed", "-Ei", "", substituteDependencyArg, "DEVELOP.md")
}

fun updateChangelog(version: String) {
val previousVersion = execute(
"sed",
"-En",
"s/^## \\[([[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]])\\].*/\\1/p",
"changelog.md"
).substringBefore("\n")
val date = SimpleDateFormat("yyyy-MM-dd").format(Date())
execute(
"sed",
"-Ei",
"",
"s/^## \\[Unreleased\\].*/## [$version](https:\\/\\/github.com\\/Orange-OpenSource\\/ods-android\\/compare\\/$previousVersion...$version) - $date/",
"changelog.md"
)
}

fun archiveDocumentation(version: String) {
copy {
from("docs")
into("docs/$version")
exclude("_*", "Gemfile*")
}

val jekyllConfigFile = File("docs/_config.yml")
jekyllConfigFile.appendText(
"""
| - scope:
| path: "$version"
| values:
| version: "$version"
|
""".trimMargin()
)
}
5 changes: 5 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_site
.sass-cache
.jekyll-cache
.jekyll-metadata
vendor
36 changes: 36 additions & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 4.3.2"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.5"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
gem "jekyll-relative-links"
gem "jekyll-remote-theme"
gem "jekyll-sass-converter", "~> 2.0"
end

# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo", ">= 1", "< 3"
gem "tzinfo-data"
end

# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]

# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
# do not have a Java counterpart.
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]
94 changes: 94 additions & 0 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
colorator (1.1.0)
concurrent-ruby (1.2.0)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
ffi (1.15.5)
forwardable-extended (2.6.0)
http_parser.rb (0.8.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
jekyll (4.3.2)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 1.0)
jekyll-sass-converter (>= 2.0, < 4.0)
jekyll-watch (~> 2.0)
kramdown (~> 2.3, >= 2.3.1)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (>= 0.3.6, < 0.5)
pathutil (~> 0.9)
rouge (>= 3.0, < 5.0)
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
jekyll-feed (0.17.0)
jekyll (>= 3.7, < 5.0)
jekyll-relative-links (0.7.0)
jekyll (>= 3.3, < 5.0)
jekyll-remote-theme (0.4.3)
addressable (~> 2.0)
jekyll (>= 3.5, < 5.0)
jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0)
rubyzip (>= 1.3.0, < 3.0)
jekyll-sass-converter (2.2.0)
sassc (> 2.0.1, < 3.0)
jekyll-seo-tag (2.8.0)
jekyll (>= 3.8, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.4)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (5.0.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
rouge (4.0.1)
rubyzip (2.3.2)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.4.2)
webrick (1.7.0)

PLATFORMS
ruby

DEPENDENCIES
http_parser.rb (~> 0.6.0)
jekyll (~> 4.3.2)
jekyll-feed (~> 0.12)
jekyll-relative-links
jekyll-remote-theme
jekyll-sass-converter (~> 2.0)
minima (~> 2.5)
tzinfo (>= 1, < 3)
tzinfo-data
wdm (~> 0.1.1)

BUNDLED WITH
2.1.2
5 changes: 5 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ relative_links:
enabled: true
collections: true
remote_theme: Orange-OpenSource/ods-jekyll-theme
defaults:
- scope:
path: ""
values:
version: ""
40 changes: 20 additions & 20 deletions docs/_data/data_menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@ toc2:
- title: Getting Started
subfolderitems:
- page: Instructions
url: /ods-android/index.html
url: /index.html

- title: Guidelines
subfolderitems:
- page: Colors
url: /ods-android/guidelines/Colors_docs
url: /guidelines/Colors_docs
- page: Typography
url: /ods-android/guidelines/Typography_docs
url: /guidelines/Typography_docs

- title: Components
subfolderitems:
- page: "App bars: bottom"
url: /ods-android/components/AppBarsBottom_docs
url: /components/AppBarsBottom_docs
- page: "App bars: top"
url: /ods-android/components/AppBarsTop_docs
url: /components/AppBarsTop_docs
- page: Buttons
url: /ods-android/components/Buttons_docs
url: /components/Buttons_docs
- page: Cards
url: /ods-android/components/Cards_docs
url: /components/Cards_docs
- page: Checkboxes
url: /ods-android/components/Checkboxes_docs
url: /components/Checkboxes_docs
- page: Chips
url: /ods-android/components/Chips_docs
url: /components/Chips_docs
- page: Dialogs
url: /ods-android/components/Dialogs_docs
url: /components/Dialogs_docs
- page: Floating action buttons
url: /ods-android/components/FloatingActionButtons_docs
url: /components/FloatingActionButtons_docs
- page: Lists
url: /ods-android/components/Lists_docs
url: /components/Lists_docs
- page: "Navigation: bottom"
url: /ods-android/components/NavigationBottom_docs
url: /components/NavigationBottom_docs
- page: Progress indicators
url: /ods-android/components/ProgressIndicators_docs
url: /components/ProgressIndicators_docs
- page: Radio buttons
url: /ods-android/components/RadioButtons_docs
url: /components/RadioButtons_docs
- page: Sliders
url: /ods-android/components/Sliders_docs
url: /components/Sliders_docs
- page: Snackbars
url: /ods-android/components/Snackbars_docs
url: /components/Snackbars_docs
- page: Switches
url: /ods-android/components/Switches_docs
url: /components/Switches_docs
- page: Tabs
url: /ods-android/components/Tabs_docs
url: /components/Tabs_docs
- page: Text fields
url: /ods-android/components/TextFields_docs
url: /components/TextFields_docs
9 changes: 7 additions & 2 deletions docs/_layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@
<div class="ods-layout container-xxl">
<main class="ods-main order-1">
{% if site.data.data_menu.toc2[0] %}
{% if page.version == "" %}
{% assign urlPrefix = "" %}
{% else %}
{% assign urlPrefix = "/" | append: page.version %}
{% endif %}
{% for item in site.data.data_menu.toc2 %}
<div class="ods-intro pt-md-4 ps-lg-4">
<h3>{{ item.title }}</h3>
Expand All @@ -128,11 +133,11 @@ <h3>{{ item.title }}</h3>
<div class="ods-content ps-lg-4 mb-3">
<ul>
{% for entry in item.subfolderitems %}
<li><a href="{{ entry.url }}">{{ entry.page }}</a>
<li><a href="{{ urlPrefix }}{{ entry.url }}">{{ entry.page }}</a>
{% if entry.subsubfolderitems[0] %}
<ul>
{% for subentry in entry.subsubfolderitems %}
<li><a href="{{ subentry.url }}">{{ subentry.page }}</a></li>
<li><a href="{{ urlPrefix }}{{ subentry.url }}">{{ subentry.page }}</a></li>
{% endfor %}
</ul>
{% endif %}
Expand Down

0 comments on commit 0389821

Please sign in to comment.