Skip to content

Commit bff6e70

Browse files
yrodieremarko-bekhta
authored andcommitted
[HSEARCH] Provide multiple getting started guides
1 parent fd849c4 commit bff6e70

8 files changed

+94
-53
lines changed

_config/site.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ projects:
193193
latest_stable:
194194
html: https://docs.jboss.org/hibernate/stable/search/api/
195195
getting_started_guide:
196-
html: https://docs.jboss.org/hibernate/search/{series.version}/getting-started/orm/en-US/html_single/
197-
pdf: https://docs.jboss.org/hibernate/search/{series.version}/getting-started/orm/en-US/pdf/hibernate_search_getting_started_orm.pdf
196+
- name: ORM
197+
html: https://docs.jboss.org/hibernate/search/{series.version}/getting-started/orm/en-US/html_single/
198+
pdf: https://docs.jboss.org/hibernate/search/{series.version}/getting-started/orm/en-US/pdf/hibernate_search_getting_started_orm.pdf
199+
- name: Standalone
200+
html: https://docs.jboss.org/hibernate/search/{series.version}/getting-started/standalone/en-US/html_single/
201+
pdf: https://docs.jboss.org/hibernate/search/{series.version}/getting-started/standalone/en-US/pdf/hibernate_search_getting_started_standalone.pdf
198202
migration_guide:
199203
html: https://docs.jboss.org/hibernate/search/{series.version}/migration/html_single/
200204
pdf: https://docs.jboss.org/hibernate/search/{series.version}/migration/pdf/hibernate_search_migration.pdf

_ext/links.rb

+30-8
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def javadoc(project, series)
1616
return DocumentRef.from_patterns(project, series, :javadoc)
1717
end
1818

19-
def getting_started_guide(project, series)
20-
return DocumentRef.from_patterns(project, series, :getting_started_guide)
19+
def getting_started_guides(project, series)
20+
return DocumentRef.from_patterns_multi(project, series, :getting_started_guide)
2121
end
2222

2323
def migration_guide(project, series)
@@ -148,13 +148,32 @@ class DocumentRef
148148

149149
def self.from_patterns(project, series, link_key)
150150
log_prefix = "#{project.name}/#{series.version}/#{link_key}: "
151-
link = series&.links&.[](link_key)
152-
link ||= project&.links&.[](link_key)
151+
link_root = series&.links&.[](link_key)
152+
link_root ||= project&.links&.[](link_key)
153+
return from_patterns_single(project, series, link_key, link_root)
154+
end
155+
156+
def self.from_patterns_multi(project, series, link_key)
157+
log_prefix = "#{project.name}/#{series.version}/#{link_key}: "
158+
link_root = series&.links&.[](link_key)
159+
link_root ||= project&.links&.[](link_key)
160+
links = []
161+
if link_root.kind_of?(Array)
162+
link_root.each do |link|
163+
links.push(from_patterns_single(project, series, link_key, link))
164+
end
165+
else
166+
links.push(from_patterns_single(project, series, link_key, link_root))
167+
end
168+
return links.compact
169+
end
170+
171+
def self.from_patterns_single(project, series, link_key, link)
172+
log_prefix = "#{project.name}/#{series.version}/#{link_key}: "
153173
if link.nil?
154174
@@logger.debug("#{log_prefix}Link is nil")
155175
return nil
156176
end
157-
@@logger.debug("#{log_prefix}Link is #{link}")
158177
displayed = link['displayed']
159178
if not displayed.nil? and not displayed
160179
@@logger.debug("#{log_prefix}Link is not displayed")
@@ -165,6 +184,8 @@ def self.from_patterns(project, series, link_key)
165184
@@logger.debug("#{log_prefix}Link is for the latest stable series only")
166185
return nil
167186
end
187+
name = link['name']
188+
@@logger.debug("#{log_prefix}Link name: #{name}")
168189
latest_stable = link['latest_stable']
169190
if latest_stable and series.latest_stable
170191
link = latest_stable
@@ -179,12 +200,13 @@ def self.from_patterns(project, series, link_key)
179200
if html_url.nil? and pdf_url.nil?
180201
return nil
181202
end
182-
return DocumentRef.new(html_url, pdf_url)
203+
return DocumentRef.new(name, html_url, pdf_url)
183204
end
184205

185-
attr_reader :html_url, :pdf_url
206+
attr_reader :name, :html_url, :pdf_url
186207

187-
def initialize(html_url, pdf_url)
208+
def initialize(name, html_url, pdf_url)
209+
@name = name
188210
@html_url = html_url
189211
@pdf_url = pdf_url
190212
end

_layouts/project/project-documentation.html.haml

+6-4
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ project_buttons_partial: project/documentation-buttons.html.haml
4747
%a.ui.right.labeled.icon.button.small(href="#{javadoc.html_url}")
4848
%i.icon.code.outline
4949
API (JavaDoc)
50-
- getting_started_guide = getting_started_guide(project_description, series)
51-
- if not getting_started_guide.nil?
50+
- getting_started_guides(project_description, series).each do |getting_started_guide|
5251
%p
5352
%span.ui.label.basic.horizontal
5453
Getting started guide
54+
- if getting_started_guide.name
55+
= "(#{getting_started_guide.name})"
5556
- if not getting_started_guide.html_url.nil?
5657
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.html_url}")
5758
%i.icon.file.text.outline
@@ -124,11 +125,12 @@ project_buttons_partial: project/documentation-buttons.html.haml
124125
%a.ui.right.labeled.icon.button.small(href="#{javadoc.html_url}")
125126
%i.icon.code.outline
126127
API (JavaDoc)
127-
- getting_started_guide = getting_started_guide(project_description, series)
128-
- if not getting_started_guide.nil?
128+
- getting_started_guides(project_description, series).each do |getting_started_guide|
129129
%p
130130
%span.ui.label.basic.horizontal
131131
Getting started guide
132+
- if getting_started_guide.name
133+
= "(#{getting_started_guide.name})"
132134
- if not getting_started_guide.html_url.nil?
133135
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.html_url}")
134136
%i.icon.file.text.outline

_layouts/project/project-getting-started.html.haml

+16-13
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ layout: project-standard
1818
.ui.grid.documentation-versions
1919
- project_description.release_series.values.each do |series|
2020
- release = series.releases[0]
21-
- getting_started_guide = getting_started_guide(project_description, series)
22-
- if not getting_started_guide.nil?
21+
- getting_started_guides = getting_started_guides(project_description, series)
22+
- if not getting_started_guides.empty?
2323
.ui.row
2424
.three.wide.column
2525
%span.ui.label.series= series.version
@@ -29,16 +29,19 @@ layout: project-standard
2929
%strong= release.version
3030
%span.detail= release.date
3131
= partial( 'project/series-status-label.html.haml', { "series" => series, "classes" => "tag" } )
32-
%p
33-
%span.ui.label.basic.horizontal
34-
Getting started guide
35-
- if not getting_started_guide.html_url.nil?
36-
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.html_url}")
37-
%i.icon.file.text.outline
38-
HTML
39-
- if not getting_started_guide.pdf_url.nil?
40-
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.pdf_url}")
41-
%i.icon.file.pdf.outline
42-
PDF
32+
- getting_started_guides.each do |getting_started_guide|
33+
%p
34+
%span.ui.label.basic.horizontal
35+
Getting started guide
36+
- if getting_started_guide.name
37+
= "(#{getting_started_guide.name})"
38+
- if not getting_started_guide.html_url.nil?
39+
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.html_url}")
40+
%i.icon.file.text.outline
41+
HTML
42+
- if not getting_started_guide.pdf_url.nil?
43+
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.pdf_url}")
44+
%i.icon.file.pdf.outline
45+
PDF
4346

4447
~ content

_layouts/project/project-releases-series.html.haml

+16-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ project_hero_partial: project/hero-series.html.haml
1414

1515
- latest_release_maven = maven(project_description, series, latest_release)
1616

17-
- getting_started_guide = getting_started_guide(project_description, series)
17+
- getting_started_guides = getting_started_guides(project_description, series)
1818
- migration_guide = migration_guide(project_description, series)
1919
- dist_sourceforge = dist_sourceforge(project_description, series, latest_release)
2020

@@ -33,7 +33,7 @@ project_hero_partial: project/hero-series.html.haml
3333
%li
3434
%a.item{:href => "#get-it"}
3535
How to get it
36-
- if not getting_started_guide.nil?
36+
- if not getting_started_guides.empty?
3737
%li
3838
%a.item{:href => "#getting_started"}
3939
Getting started
@@ -237,7 +237,7 @@ project_hero_partial: project/hero-series.html.haml
237237
%a{:href => "#releases"}
238238
here.
239239

240-
- if not getting_started_guide.nil?
240+
- if not getting_started_guides.empty?
241241
%h2{:id => "getting_started"} Getting started
242242
- if series.status == 'end-of-life'
243243
:asciidoc
@@ -261,15 +261,19 @@ project_hero_partial: project/hero-series.html.haml
261261
====
262262
%p
263263
If you want to start using #{project_description.name} #{series.version}, please refer to the getting started guide:
264-
%p
265-
- if not getting_started_guide.html_url.nil?
266-
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.html_url}")
267-
%i.icon.file.text.outline
268-
HTML
269-
- if not getting_started_guide.pdf_url.nil?
270-
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.pdf_url}")
271-
%i.icon.file.pdf.outline
272-
PDF
264+
- getting_started_guides.each do |getting_started_guide|
265+
%p
266+
- if getting_started_guide.name
267+
%span.ui.label.basic.horizontal
268+
= getting_started_guide.name
269+
- if not getting_started_guide.html_url.nil?
270+
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.html_url}")
271+
%i.icon.file.text.outline
272+
HTML
273+
- if not getting_started_guide.pdf_url.nil?
274+
%a.ui.right.labeled.icon.button.small(href="#{getting_started_guide.pdf_url}")
275+
%i.icon.file.pdf.outline
276+
PDF
273277

274278
- if not migration_guide.nil?
275279
%h2{:id => "migrate"} Migrating

_partials/project/about-buttons.html.haml

+9-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
- stable_series = latest_stable_series(real_page)
44
- series = latest_series(real_page)
55
- dev_series = next_dev_series(real_page)
6-
- get_started_url = project_description.nil? || stable_series.nil? ? nil : getting_started_guide(project_description, stable_series)&.html_url
6+
- getting_started_guides = project_description.nil? || stable_series.nil? ? [] : getting_started_guides(project_description, stable_series)
77

8-
- if not get_started_url.nil?
9-
.jumbotron-button
10-
%a.ui.small.right.labeled.icon.button{:href => "#{get_started_url}"}
11-
%i.right.arrow.icon
12-
Getting started
8+
- if not getting_started_guides.empty?
9+
- getting_started_guides.each do |getting_started_guide|
10+
.jumbotron-button
11+
%a.ui.small.right.labeled.icon.button{:href => "#{getting_started_guide&.html_url}"}
12+
%i.right.arrow.icon
13+
Getting started
14+
- if getting_started_guide.name
15+
= "(#{getting_started_guide.name})"
1316
- if not (stable_series.nil? && dev_series.nil?)
1417
- unless stable_series.nil?
1518
.jumbotron-button

_partials/project/documentation-buttons.html.haml

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
- project_description = site.projects[real_page.project]
33
- stable_series = latest_stable_series(real_page)
44
- series = latest_series(real_page)
5-
- get_started_url = stable_series.nil? ? nil : getting_started_guide(project_description, stable_series)&.html_url
5+
- getting_started_guides = stable_series.nil? ? [] : getting_started_guides(project_description, stable_series)
66

7-
- if not get_started_url.nil?
8-
.jumbotron-button
9-
%a.ui.small.right.labeled.icon.button{:href => "#{get_started_url}"}
10-
%i.right.arrow.icon
11-
Getting started
7+
- if not getting_started_guides.empty?
8+
- getting_started_guides.each do |getting_started_guide|
9+
.jumbotron-button
10+
%a.ui.small.right.labeled.icon.button{:href => "#{getting_started_guide&.html_url}"}
11+
%i.right.arrow.icon
12+
Getting started
13+
- if getting_started_guide.name
14+
= "(#{getting_started_guide.name})"
1215
- unless stable_series.nil?
1316
.jumbotron-button
1417
- reference_doc = reference_doc(project_description, series)

reactive/index.html.haml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ project: reactive
77
- project = site.projects[page.project]
88
-# Latest series available unless a stable release exists
99
- series = project.latest_stable_series.nil? ? project.latest_series : project.latest_stable_series
10-
- getting_started_guide = getting_started_guide(project, series)
10+
- getting_started_guides = getting_started_guides(project, series)
1111

1212
-# Center body
1313
.feature-block
1414
:asciidoc
15-
:getting_started_guide_link: #{getting_started_guide.html_url}
15+
:getting_started_guide_link: #{getting_started_guides.first.html_url}
1616
:introduction: http://hibernate.org/reactive/documentation/1.0/reference/html_single/
1717
:build: http://hibernate.org/reactive/documentation/1.0/reference/html_single/#_including_hibernate_reactive_in_your_project_build
1818
:config: http://hibernate.org/reactive/documentation/1.0/reference/html_single/#_basic_configuration

0 commit comments

Comments
 (0)