giblish 2.0.0.pre.alpha1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/unit_tests.yml +3 -3
- data/.gitignore +0 -1
- data/.ruby-version +1 -1
- data/Changelog.adoc +29 -4
- data/README.adoc +12 -10
- data/docs/howtos/{trigger_generation.adoc → setup_static_site.adoc} +23 -27
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/Render Documents.png +0 -0
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/View Documents.png +0 -0
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/deploy_with_hooks.graphml +0 -0
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/deploy_with_hooks.svg +0 -0
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/deploy_with_jenkins.graphml +0 -0
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/deploy_with_jenkins.svg +0 -0
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/docgen_github.puml +0 -0
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/giblish_deployment.graphml +0 -0
- data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/post-receive-example.sh +0 -0
- data/docs/reference/develop_and_build.adoc +27 -0
- data/giblish.gemspec +1 -1
- data/lib/giblish/application.rb +57 -52
- data/lib/giblish/treeconverter.rb +95 -30
- data/lib/giblish/version.rb +1 -1
- data/web_apps/gh_webhook_trigger/gh_webhook_trigger.rb +1 -30
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 692017a96101341d60e2a0243d6b22441f75dab56904aa97a91f9c272e3c0630
|
4
|
+
data.tar.gz: f4e6e3bc7843484ee414b880ed562b8d94a49913f6637ee5a8c7233d56b99491
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32186232754bfc2362c1ac18465747de784c8ce950226223bd67f342c0145cac91af6b0c6364a0c3b211cfba11367bc0959d08a01faf191d9f021f695231239f
|
7
|
+
data.tar.gz: b89358a5bb1945492ea14d0e74a42f9364da494a378911b84b062f632353b0350424b709da7d637d9c16095a778d8aa95a7a90a419376b02cb50e634b4b8e2a4
|
@@ -9,7 +9,7 @@ jobs:
|
|
9
9
|
runs-on: ubuntu-latest
|
10
10
|
strategy:
|
11
11
|
matrix:
|
12
|
-
ruby-version: ["3.0", "3.1"]
|
12
|
+
ruby-version: ["2.7", "3.0", "3.1"]
|
13
13
|
|
14
14
|
steps:
|
15
15
|
- name: Install binutils
|
@@ -17,9 +17,9 @@ jobs:
|
|
17
17
|
sudo apt -y install binutils
|
18
18
|
- name: Install needed packages
|
19
19
|
run: |
|
20
|
-
sudo apt-get -y install libpango1.0-dev graphviz
|
20
|
+
sudo apt-get -y install libpango1.0-dev graphviz libwebp-dev libzstd-dev
|
21
21
|
- name: Checkout Giblish
|
22
|
-
uses: actions/checkout@
|
22
|
+
uses: actions/checkout@v3
|
23
23
|
- name: Set up Ruby
|
24
24
|
uses: ruby/setup-ruby@v1
|
25
25
|
with:
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.3
|
data/Changelog.adoc
CHANGED
@@ -1,17 +1,42 @@
|
|
1
1
|
= giblish changelog
|
2
|
+
:docid: G-006
|
2
3
|
|
3
|
-
== Not yet in place
|
4
|
+
== Some of the things Not yet in place
|
4
5
|
|
6
|
+
* Investigate how to remove tmp/cache files and dirs during graph generation
|
5
7
|
* Update docs for giblish.
|
6
|
-
** write
|
8
|
+
** write instructions for github webhook triggered generation
|
7
9
|
* Update the default css for giblish html generation.
|
10
|
+
* Implement a way for a user to customize the index page
|
11
|
+
|
12
|
+
== v2.1.0
|
13
|
+
|
14
|
+
Changes/New functionality::
|
15
|
+
* asciidoctor-diagram is required if it exists, this makes diagrams in documents render.
|
16
|
+
* giblish now complies with these precedence rules for document attributes:
|
17
|
+
.. An attribute passed to the API or CLI whose value does not end in @
|
18
|
+
.. (giblish specific) An attribute defined in an attribute provider for a specific source node
|
19
|
+
.. An attribute defined in the document
|
20
|
+
.. An attribute passed to the API or CLI whose value or name ends in @
|
21
|
+
.. (giblish specific) The default value set by giblish, if applicable
|
22
|
+
.. The default value set by asciidoctor, if applicable
|
23
|
+
+
|
24
|
+
this is an augumentation of the ones found here: https://docs.asciidoctor.org/asciidoc/latest/attributes/assignment-precedence/
|
25
|
+
|
26
|
+
== v2.0.0
|
27
|
+
|
28
|
+
This is a breaking release because the internal dependencies to asciidoctor-pdf has been bumped from one major release to the next. `giblish` itself has not seen any major, internal, updates.
|
29
|
+
|
30
|
+
Breaking changes::
|
31
|
+
* Dependency on asciidoctor-pdf has been bumped to v2.3
|
32
|
+
* rename some pdf attributes internally in giblish to comply with the new version of asciidoctor-pdf
|
8
33
|
|
9
34
|
== v1.0.0
|
10
35
|
|
11
36
|
This release includes a complete refactoring of almost the entire code base.
|
12
37
|
|
13
38
|
Breaking changes::
|
14
|
-
* The '-w' flag is removed
|
39
|
+
* The '-w' flag is removed
|
15
40
|
* The text search parameters interface has changed completely. A written specification of this interface is included in the docs.
|
16
41
|
* The '-r' flag will, for html generation, *copy everything* under the given directory to the target location.
|
17
42
|
** the previous restriction on folder names has been removed.
|
@@ -36,7 +61,7 @@ Changes/New functionality::
|
|
36
61
|
** the implementation of the server-side search tools are written completely in ruby and does no longer depend on an external 'grep' tool.
|
37
62
|
** almost all needed infrastructure for implementing a server-side search script has been implemented within the 'giblish' gem.
|
38
63
|
* The asciidoctor toolchain dependencies are updated to the latest versions (at the time of release).
|
39
|
-
|
64
|
+
|
40
65
|
|
41
66
|
== v0.8.0
|
42
67
|
|
data/README.adoc
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
= giblish
|
2
2
|
:docid: G-001
|
3
3
|
:numbered:
|
4
|
+
:toc: preamble
|
5
|
+
:toclevels: 1
|
4
6
|
|
5
7
|
image::https://github.com/rillbert/giblish/actions/workflows/unit_tests.yml/badge.svg["Build Status"]
|
6
8
|
|
7
|
-
[abstract]
|
8
|
-
== Purpose
|
9
9
|
|
10
10
|
giblish converts a source directory tree containing AsciiDoc files to a destination directory tree containing the corresponding html or pdf files. It adds some handy tools for easier navigation of the resulting destination tree.
|
11
11
|
|
@@ -23,11 +23,11 @@ IMPORTANT: The examples below are *not* the official documentation for the corre
|
|
23
23
|
|
24
24
|
|Raspberry Pi documentation
|
25
25
|
|https://www.rillbert.se/giblish_examples/rpi_docs/giblish_example/index.html[example]
|
26
|
-
|The
|
26
|
+
|The project's official documentation site uses Jekyl for site generation, the link points to a mirror where some small tweaks to the docs were made to make them suitable for generation with giblish.
|
27
27
|
|
28
28
|
|The *old* asciidoctor docs
|
29
29
|
|https://www.rillbert.se/giblish_examples/asciidoctor_docs/master/newindex.html[example]
|
30
|
-
|An example of how giblish can generate the master branch of the official asciidoc.org documentation git repo
|
30
|
+
|An example of how giblish can generate the master branch of the *old, deprecated* official asciidoc.org documentation git repo.
|
31
31
|
|
32
32
|
|===
|
33
33
|
|
@@ -45,7 +45,9 @@ The features of giblish include:
|
|
45
45
|
|
46
46
|
== Dependencies and credits
|
47
47
|
|
48
|
-
Giblish uses the awesome
|
48
|
+
Giblish uses the awesome `asciidoctor` and `asciidoctor-pdf` projects under the hood. Thank you @mojavelinux and others for making these brilliant tools available!!
|
49
|
+
|
50
|
+
The official documentation of these tools as well as extensive information about the AsciiDoc syntax can be found at https://docs.asciidoctor.org
|
49
51
|
|
50
52
|
== Installation
|
51
53
|
|
@@ -107,7 +109,7 @@ Example document one::
|
|
107
109
|
= Document one
|
108
110
|
:toc:
|
109
111
|
:numbered:
|
110
|
-
:docid:
|
112
|
+
:docid: AB-001
|
111
113
|
|
112
114
|
== Purpose
|
113
115
|
|
@@ -120,16 +122,16 @@ Example document two::
|
|
120
122
|
= Document two
|
121
123
|
:toc:
|
122
124
|
:numbered:
|
123
|
-
:docid:
|
125
|
+
:docid: AB-002
|
124
126
|
|
125
127
|
== Purpose
|
126
128
|
|
127
|
-
To illustrate the use of doc id. You can refer to document one as <<:docid:
|
129
|
+
To illustrate the use of doc id. You can refer to document one as <<:docid:AB-001>>. This will display a clickable link with the doc id (AB-001 in this case).
|
128
130
|
|
129
131
|
You can use the same syntax as the normal asciidoc cross-ref but replace 'xref' with ':docid:' as shown below:
|
130
132
|
|
131
|
-
* <<:docid:
|
132
|
-
* <<:docid:
|
133
|
+
* <<:docid:AB-002#purpose>> to refer to a specific section or anchor.
|
134
|
+
* <<:docid:AB-002#purpose,The purpose section>> to refer to a specific section and display a specific text for the link.
|
133
135
|
----
|
134
136
|
|
135
137
|
The above reference will work even if either document changes location or file name as long as both documents are parsed by giblish in the same run.
|
@@ -1,5 +1,6 @@
|
|
1
|
-
=
|
2
|
-
|
1
|
+
= Setup a static website
|
2
|
+
using giblish and git
|
3
|
+
:imagesdir: setup_static_site_assets
|
3
4
|
:numbered:
|
4
5
|
:docid: G-003
|
5
6
|
:toc: left
|
@@ -8,18 +9,18 @@
|
|
8
9
|
|
9
10
|
To describe how to use `giblish` as a tool for creating a static web site backed by a git repo that is automatically generated each time a contributor push changes to the git repo.
|
10
11
|
|
11
|
-
This text covers the
|
12
|
+
This text covers the following deployment scenarios:
|
12
13
|
|
13
|
-
. Using a git hook together with a
|
14
|
+
. Using a git hook together with a shell script.
|
14
15
|
. Using a git hook together with Jenkins.
|
15
16
|
|
16
|
-
They have been tested on Linux servers (Ubuntu). Most of the tools and scripts should work on a Windows server as well but might need some tweaking and is
|
17
|
+
They have been tested on Linux servers (Ubuntu). Most of the tools and scripts should work on a Windows server as well but might need some tweaking and it is not tested.
|
17
18
|
|
18
19
|
If you want to dive straight in and setup one of the scenarios below, jump to <<setup_instructions>>, otherwise read on for some examples and considerations.
|
19
20
|
|
20
21
|
== Git hook and shell script
|
21
22
|
|
22
|
-
This requires the least number of dependencies
|
23
|
+
This requires the least number of external dependencies but is limited.
|
23
24
|
|
24
25
|
.Deploy using git hook and shell script
|
25
26
|
image::deploy_with_hooks.svg[]
|
@@ -30,13 +31,13 @@ A 'Main Repo'::
|
|
30
31
|
The common (bare) git repo used by all content writers to push updates to. This repo shall be setup with a server-side hook (_post-receive_) that initiates the html generation and is triggered by each push to the repo.
|
31
32
|
|
32
33
|
A 'Staging Repo'::
|
33
|
-
A mirror of the _Main Repo_ that
|
34
|
+
A mirror of the _Main Repo_ that fulfils two functions:
|
34
35
|
|
35
36
|
. to provide a checked-out working tree with the source files (adoc files).
|
36
37
|
. to provide a script that uses giblish to generate html documents and publish those docs to a location where a web server can access them.
|
37
38
|
|
38
|
-
Web Server::
|
39
|
-
Apache,
|
39
|
+
A Web Server::
|
40
|
+
Apache, Nginx or other web server that provides clients with HTML pages located somewhere on the file system on the server (e.g under /var/www/... )
|
40
41
|
|
41
42
|
=== Pros & Cons
|
42
43
|
|
@@ -48,7 +49,7 @@ Cons::
|
|
48
49
|
* The hook and publish scripts provided with giblish runs synchronously at each push from a _Doc Writer_ to the _Main Repo_. The time it takes to generate the HTML docs from the adoc source will thus be added to each push to the _Main Repo_.
|
49
50
|
* You need to manually setup the _Staging Repo_ on the server and this is a bit more 'hackish' than letting a build orchestrator tool implement a proper 'build' of your documents. You might for example end up with race conditions if two pushes to the _Main Repo_ are done close in time.
|
50
51
|
|
51
|
-
|
52
|
+
== Using a combination of Jenkins and git hook
|
52
53
|
|
53
54
|
This setup adds a Jenkins (or similar build orchestrator) installation so it is more tools to setup but offer more flexibility and performance. It is also more robust and thus more 'production friendly'.
|
54
55
|
|
@@ -66,9 +67,9 @@ Jenkins instance::
|
|
66
67
|
A running instance of Jenkins and one or more defined build jobs that use giblish to build the HTML documents.
|
67
68
|
|
68
69
|
Web Server::
|
69
|
-
Apache,
|
70
|
+
Apache, Nginx or other web server that provides clients with HTML pages located somewhere on the file system on the server (e.g under /var/www/... )
|
70
71
|
|
71
|
-
|
72
|
+
=== Pros & cons
|
72
73
|
|
73
74
|
Pros::
|
74
75
|
* Using Jenkins enables a lot of flexibility and scaleability. You can setup multiple Jenkins agents to increase performance, you can define many build jobs where each job builds either a particular branch from a particular git repo or many branches from one or many repos.
|
@@ -83,9 +84,9 @@ Follow the instructions below to get one of the above setups running on your ser
|
|
83
84
|
|
84
85
|
=== Some preliminary notes
|
85
86
|
|
86
|
-
IMPORTANT: Setting up permissions and secure your setup from unwanted access is outside the scope of these instructions. You must understand and implement the proper
|
87
|
+
IMPORTANT: Setting up permissions and secure your setup from unwanted access is outside the scope of these instructions. You must understand and implement the proper authentication rules for your use case.
|
87
88
|
|
88
|
-
|
89
|
+
git server side hooks are used in the instructions below. For details on git hooks see https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks[this doc].
|
89
90
|
|
90
91
|
[[common_setup]]
|
91
92
|
=== Initial setup
|
@@ -94,9 +95,9 @@ These steps are common to both deployment scenarios.
|
|
94
95
|
|
95
96
|
giblish setup::
|
96
97
|
. Install ruby on the _Server_ (a version no more than 18 months old)
|
97
|
-
. Install giblish on the _Server_
|
98
|
+
. Install giblish on the _Server_. See e.g. <<:docid:G-001>>
|
98
99
|
|
99
|
-
git and
|
100
|
+
git and git repo setup::
|
100
101
|
. Install git on the _Server_.
|
101
102
|
. Setup the *bare* _Main Repo_ on the _Server_ by either.
|
102
103
|
.. Copy a bare repo you already use to the _Server_ file system.
|
@@ -104,7 +105,7 @@ git and gitrepo setup::
|
|
104
105
|
+
|
105
106
|
NOTE: If you start with an empty, bare, _Main Repo_ on the _Server_, it is a good idea to directly clone it to your local machine, commit some content to the 'master' branch and push the result back to the _Main Repo_. An empty, bare repo does not even contain a 'master' branch from the start and this can lead to some edge cases that complicate things.
|
106
107
|
|
107
|
-
===
|
108
|
+
=== Scenario 1 - use a git hook and shell script
|
108
109
|
|
109
110
|
First, follow the steps described in <<common_setup>>. Then proceed with the steps below.
|
110
111
|
|
@@ -125,13 +126,10 @@ git clone file:///usr/local/main_repo.git
|
|
125
126
|
+
|
126
127
|
.Find the `post-receive` template in the giblish gem
|
127
128
|
====
|
128
|
-
|
129
|
-
|
130
|
-
/
|
129
|
+
run the following to copy the post-receive template to your current directory:
|
130
|
+
|
131
|
+
cp $(dirname $(gem which giblish))/../scripts/hooks/post-receive.example .
|
131
132
|
|
132
|
-
and the template hook can be found under
|
133
|
-
|
134
|
-
/var/lib/gems/2.6.0/gems/giblish-0.7.0/scripts/hooks/post-receive.example
|
135
133
|
====
|
136
134
|
|
137
135
|
. Rename the copy to `post-receive`
|
@@ -143,8 +141,6 @@ That's it. You can now push to your _Main Repo_ and the `post-receive` hook will
|
|
143
141
|
|
144
142
|
=== Setup the git hook and Jenkins scenario
|
145
143
|
|
146
|
-
TBD...
|
147
|
-
|
148
144
|
First, follow the steps described in <<common_setup>>. Then proceed with the steps below.
|
149
145
|
|
150
146
|
==== Sequence for generating documents
|
@@ -162,7 +158,7 @@ image::Render Documents.png[]
|
|
162
158
|
====
|
163
159
|
[source,bash]
|
164
160
|
----
|
165
|
-
include
|
161
|
+
include::../../scripts/hooks/post-receive.example[]
|
166
162
|
----
|
167
163
|
====
|
168
164
|
|
@@ -175,6 +171,6 @@ Below is an example of a `post-update` hook that triggers Jenkins jobs after a p
|
|
175
171
|
====
|
176
172
|
[source,bash]
|
177
173
|
----
|
178
|
-
include
|
174
|
+
include::../../scripts/hooks/post-update.example[]
|
179
175
|
----
|
180
176
|
====
|
File without changes
|
File without changes
|
data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/deploy_with_hooks.graphml
RENAMED
File without changes
|
File without changes
|
data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/deploy_with_jenkins.graphml
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/docs/howtos/{trigger_generation_im → setup_static_site_assets}/giblish_deployment.graphml
RENAMED
File without changes
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
= Developing and building giblish
|
2
|
+
:docid: G-005
|
3
|
+
|
4
|
+
NOTE: giblish is developed using the https://github.com/rbenv/rbenv[rbenv] ruby version manager. It is *strongly recommended* to setup and use this tool when developing or building giblish.
|
5
|
+
|
6
|
+
[[build_gem]]
|
7
|
+
== Building giblish as a gem
|
8
|
+
|
9
|
+
Setup dependencies::
|
10
|
+
. Setup your `rbenv` environment.
|
11
|
+
. Check out the branch you want to build.
|
12
|
+
. Open a terminal in the top directory of the checked-out branch.
|
13
|
+
. Install giblish' dependencies using `bundle install`
|
14
|
+
.. *Note* The `mathematical` gem is currently a development dependency for giblish and it can be a bit tricky to build and install its native dependencies. How to do that is outside the scope of this document.
|
15
|
+
|
16
|
+
Run the unit tests::
|
17
|
+
. Run the unit tests using `bundle exec rake`.
|
18
|
+
|
19
|
+
Build the gem::
|
20
|
+
. Build the gem using `bundle exec gem build`
|
21
|
+
|
22
|
+
== Publish a release
|
23
|
+
|
24
|
+
. Create a new release in GitHub using the same version nr as stated in `.../lib/version.rb`.
|
25
|
+
. Build the gem using the steps from <<build_gem>>.
|
26
|
+
. Publish the gem to https://rubygems.org/ by running `bundle exec gem push giblish-<version>.gem`
|
27
|
+
|
data/giblish.gemspec
CHANGED
@@ -49,7 +49,6 @@ Gem::Specification.new do |spec|
|
|
49
49
|
spec.add_development_dependency "standard", "~> 1.16"
|
50
50
|
spec.add_development_dependency "rake", "~> 13.0"
|
51
51
|
spec.add_development_dependency "oga", "~> 3.3"
|
52
|
-
# spec.add_development_dependency "thor", "~> 0.20.3"
|
53
52
|
spec.add_development_dependency "thor", "~> 1.2"
|
54
53
|
spec.add_development_dependency "asciidoctor-mathematical", "~> 0.3.5"
|
55
54
|
# needed for the sinatra-based apps
|
@@ -61,6 +60,7 @@ Gem::Specification.new do |spec|
|
|
61
60
|
# Run-time deps
|
62
61
|
# 'matrix' needed because of incompatibilities between prawn v2.4
|
63
62
|
# and ruby 3.1
|
63
|
+
# sorbet-runtime
|
64
64
|
spec.add_runtime_dependency "matrix", "~>0.4"
|
65
65
|
spec.add_runtime_dependency "warning", "~>1.2"
|
66
66
|
spec.add_runtime_dependency "asciidoctor", "~>2.0", ">= 2.0.17"
|
data/lib/giblish/application.rb
CHANGED
@@ -5,54 +5,54 @@ require_relative "gitrepos/checkoutmanager"
|
|
5
5
|
|
6
6
|
module Giblish
|
7
7
|
# The app class for the giblish application
|
8
|
-
class Application
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
8
|
+
# class Application
|
9
|
+
# # returns on success, raises otherwise
|
10
|
+
# def run(args)
|
11
|
+
# # force immediate output
|
12
|
+
# $stdout.sync = true
|
13
|
+
|
14
|
+
# # setup logging
|
15
|
+
# Giblog.setup
|
16
|
+
# Giblog.logger.level = Logger::INFO
|
17
|
+
|
18
|
+
# # Parse cmd line
|
19
|
+
# cmdline = CmdLine.new.parse(args)
|
20
|
+
# Giblog.logger.level = cmdline.log_level
|
21
|
+
|
22
|
+
# Giblog.logger.debug { "cmd line args: #{cmdline.inspect}" }
|
23
|
+
|
24
|
+
# # build a tree of files matching user's regexp selection
|
25
|
+
# src_tree = PathTree.build_from_fs(cmdline.srcdir) do |p|
|
26
|
+
# if cmdline.exclude_regex&.match(p.to_s)
|
27
|
+
# false
|
28
|
+
# else
|
29
|
+
# (cmdline.include_regex =~ p.to_s)
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# if src_tree.nil?
|
33
|
+
# Giblog.logger.warn { "Did not find any files to convert" }
|
34
|
+
# return
|
35
|
+
# end
|
36
|
+
|
37
|
+
# app = Configurator.new(cmdline, src_tree)
|
38
|
+
# app.tree_converter.run
|
39
|
+
|
40
|
+
# Giblog.logger.info { "Giblish is done!" }
|
41
|
+
# end
|
42
|
+
|
43
|
+
# # does not return, exits with status code
|
44
|
+
# def run_from_cmd_line
|
45
|
+
# begin
|
46
|
+
# run(ARGV)
|
47
|
+
# exit_code = 0
|
48
|
+
# rescue => exc
|
49
|
+
# Giblog.logger.error { exc.message }
|
50
|
+
# Giblog.logger.error { exc.backtrace }
|
51
|
+
# exit_code = 1
|
52
|
+
# end
|
53
|
+
# exit(exit_code)
|
54
|
+
# end
|
55
|
+
# end
|
56
56
|
|
57
57
|
class DirTreeConvert
|
58
58
|
# This class provides a file as the source for the asciidoc info and
|
@@ -197,15 +197,20 @@ module Giblish
|
|
197
197
|
Giblog.logger.level = Logger::INFO
|
198
198
|
|
199
199
|
# Parse cmd line
|
200
|
-
user_opts = CmdLine.new.parse(args)
|
201
|
-
Giblog.logger.level = user_opts.log_level
|
202
|
-
Giblog.logger.debug { "cmd line args: #{user_opts.inspect}" }
|
200
|
+
@user_opts = CmdLine.new.parse(args)
|
201
|
+
Giblog.logger.level = @user_opts.log_level
|
202
|
+
Giblog.logger.debug { "cmd line args: #{@user_opts.inspect}" }
|
203
203
|
|
204
204
|
# Select the coversion instance to use
|
205
|
-
@converter = select_conversion(user_opts)
|
205
|
+
@converter = select_conversion(@user_opts)
|
206
206
|
end
|
207
207
|
|
208
208
|
def run
|
209
|
+
begin
|
210
|
+
require "asciidoctor-diagram"
|
211
|
+
rescue LoadError
|
212
|
+
Giblog.logger.warn { "Did not find asciidoctor-diagram installed, diagrams will not be rendered." }
|
213
|
+
end
|
209
214
|
# do the conversion
|
210
215
|
@converter.run
|
211
216
|
end
|
@@ -156,20 +156,20 @@ module Giblish
|
|
156
156
|
}
|
157
157
|
|
158
158
|
# see https://docs.asciidoctor.org/asciidoctor/latest/api/options/
|
159
|
-
|
160
|
-
backend: "html5",
|
159
|
+
DEFAULT_ADOC_API_OPTS = {
|
160
|
+
# backend: "html5",
|
161
161
|
# base_dir:
|
162
|
-
catalog_assets: false,
|
162
|
+
# catalog_assets: false,
|
163
163
|
# converter:
|
164
|
-
doctype: "article",
|
164
|
+
# doctype: "article",
|
165
165
|
# eruby:
|
166
166
|
# ignore extention stuff
|
167
|
-
header_only: false,
|
167
|
+
# header_only: false,
|
168
168
|
# logger:
|
169
|
-
mkdirs: false,
|
170
|
-
parse: true,
|
169
|
+
# mkdirs: false,
|
170
|
+
# parse: true,
|
171
171
|
safe: :unsafe,
|
172
|
-
sourcemap: false,
|
172
|
+
# sourcemap: false,
|
173
173
|
# template stuff TBD,
|
174
174
|
# to_file:
|
175
175
|
# to_dir:
|
@@ -192,12 +192,67 @@ module Giblish
|
|
192
192
|
failure: ->(src, dst, dst_rel_path, ex, logstr) { TreeConverter.on_failure(src, dst, dst_rel_path, ex, logstr) }
|
193
193
|
})
|
194
194
|
|
195
|
-
#
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
195
|
+
# cache external configuration
|
196
|
+
@config_opts = opts.dup
|
197
|
+
end
|
198
|
+
|
199
|
+
# Resolve the document attributes according to the precedence.
|
200
|
+
#
|
201
|
+
# According to https://docs.asciidoctor.org/asciidoc/latest/attributes/assignment-precedence/
|
202
|
+
# The attribute precedence is:
|
203
|
+
# 1. An attribute passed to the API or CLI whose value does not end in @
|
204
|
+
# 2. An attribute defined in the document
|
205
|
+
# 3. An attribute passed to the API or CLI whose value or name ends in @
|
206
|
+
# 4. The default value of the attribute, if applicable
|
207
|
+
#
|
208
|
+
# giblish adds the following rules:
|
209
|
+
# 1.5 An attribute defined in an attribute provider for a specific source node
|
210
|
+
# 3.5 The default value set by giblish, if applicable
|
211
|
+
def resolve_doc_attributes(doc_src, node_attr)
|
212
|
+
# rule 3.5
|
213
|
+
doc_attr = DEFAULT_ADOC_DOC_ATTRIBS.dup
|
214
|
+
|
215
|
+
# sort attribs into soft and hard (rule 1 and 3)
|
216
|
+
soft_attr = {}
|
217
|
+
hard_attr = {}
|
218
|
+
@config_opts.fetch(:adoc_doc_attribs, {}).each do |k, v|
|
219
|
+
ks = k.to_s.strip
|
220
|
+
vs = v.to_s.strip
|
221
|
+
|
222
|
+
if ks.end_with?("@")
|
223
|
+
soft_attr[ks[0..]] = vs
|
224
|
+
next
|
225
|
+
end
|
226
|
+
if vs.end_with?("@")
|
227
|
+
soft_attr[ks] = vs[0..]
|
228
|
+
next
|
229
|
+
end
|
230
|
+
hard_attr[ks] = vs
|
231
|
+
end
|
232
|
+
|
233
|
+
# rule 3.
|
234
|
+
doc_attr.merge!(soft_attr)
|
235
|
+
|
236
|
+
# rule 2
|
237
|
+
Giblish.process_header_lines(doc_src.lines) do |line|
|
238
|
+
a = /^:(.+):(.*)$/.match(line)
|
239
|
+
next unless a
|
240
|
+
@logger.debug { "got header attr from doc: #{a[1]} : #{a[2]}" }
|
241
|
+
doc_attr[a[1].strip] = a[2].strip
|
242
|
+
end
|
243
|
+
|
244
|
+
@logger.debug { "idprefix before: #{doc_attr["idprefix"]}" }
|
245
|
+
|
246
|
+
# rule 1.5
|
247
|
+
doc_attr.merge!(node_attr)
|
248
|
+
|
249
|
+
# rule 1.
|
250
|
+
doc_attr.merge!(hard_attr)
|
251
|
+
|
252
|
+
@logger.debug { "idprefix after: #{doc_attr["idprefix"]}" }
|
253
|
+
|
254
|
+
# @logger&.debug { "Header attribs: #{doc_attr}" }
|
255
|
+
doc_attr
|
201
256
|
end
|
202
257
|
|
203
258
|
# require the following methods to be available from the src node:
|
@@ -216,34 +271,44 @@ module Giblish
|
|
216
271
|
@logger&.info { "Converting #{src_node.pathname} and store result under #{dst_node.parent.pathname}" }
|
217
272
|
|
218
273
|
# merge the common api opts with node specific
|
219
|
-
api_opts =
|
274
|
+
api_opts = DEFAULT_ADOC_API_OPTS.dup
|
275
|
+
api_opts.merge!(@config_opts.fetch(:adoc_api_opts, {}))
|
220
276
|
api_opts.merge!(src_node.api_options(src_node, dst_node, dst_top)) if src_node.respond_to?(:api_options)
|
221
|
-
api_opts[:attributes].merge!(src_node.document_attributes(src_node, dst_node, dst_top)) if src_node.respond_to?(:document_attributes)
|
222
277
|
|
223
278
|
# use a new logger instance for each conversion
|
224
279
|
adoc_logger = Giblish::AsciidoctorLogger.new(@logger, @adoc_log_level)
|
225
280
|
|
226
281
|
begin
|
227
|
-
|
282
|
+
doc_src = src_node.adoc_source(src_node, dst_node, dst_top)
|
283
|
+
|
284
|
+
node_attr = src_node.respond_to?(:document_attributes) ?
|
285
|
+
src_node.document_attributes(src_node, dst_node, dst_top) : {}
|
286
|
+
doc_attr = resolve_doc_attributes(doc_src, node_attr)
|
287
|
+
# piggy-back our own info on the doc attributes hash so that
|
288
|
+
# asciidoctor extensions can use this info later on
|
289
|
+
doc_attr["giblish-info"] = {
|
290
|
+
src_node: src_node,
|
291
|
+
dst_node: dst_node,
|
292
|
+
dst_top: dst_top
|
293
|
+
}
|
294
|
+
|
295
|
+
# load the source to enable access to doc attributes and properties
|
228
296
|
#
|
229
|
-
# NOTE:
|
297
|
+
# NOTE: 'parse' is set to false to prevent preprocessor extensions to be run as part
|
230
298
|
# of loading the document. We want them to run during the 'convert' call later when
|
231
299
|
# doc attribs have been amended.
|
232
|
-
|
300
|
+
#
|
301
|
+
# NOTE2: by trial-and-error, it seems that some document attributes must be set when
|
302
|
+
# calling 'load' and not added after the call and before the 'convert' call to have
|
303
|
+
# the expected effect (e.g. idprefix).
|
304
|
+
doc = Asciidoctor.load(doc_src, api_opts.merge(
|
233
305
|
{
|
306
|
+
attributes: doc_attr,
|
234
307
|
parse: false,
|
235
308
|
logger: adoc_logger
|
236
309
|
}
|
237
310
|
))
|
238
311
|
|
239
|
-
# piggy-back our own info on the doc attributes hash so that
|
240
|
-
# asciidoctor extensions can use this info later on
|
241
|
-
doc.attributes["giblish-info"] = {
|
242
|
-
src_node: src_node,
|
243
|
-
dst_node: dst_node,
|
244
|
-
dst_top: dst_top
|
245
|
-
}
|
246
|
-
|
247
312
|
# update the destination node with the correct file suffix. This is dependent
|
248
313
|
# on the type of conversion performed
|
249
314
|
dst_node.name = dst_node.name.sub_ext(doc.attributes["outfilesuffix"])
|
@@ -252,11 +317,11 @@ module Giblish
|
|
252
317
|
# make sure the dst dir exists
|
253
318
|
d.dirname.mkpath
|
254
319
|
|
255
|
-
# write the converted doc to
|
256
|
-
output = doc.convert(api_opts
|
320
|
+
# do the conversion and write the converted doc to file
|
321
|
+
output = doc.convert(api_opts)
|
257
322
|
doc.write(output, d.to_s)
|
258
323
|
|
259
|
-
# give user the opportunity to eg store the result of the conversion
|
324
|
+
# give the user the opportunity to eg store the result of the conversion
|
260
325
|
# as data in the destination node
|
261
326
|
@conv_cb[:success]&.call(src_node, dst_node, dst_top, doc, adoc_logger.in_mem_storage.string)
|
262
327
|
true
|
data/lib/giblish/version.rb
CHANGED
@@ -17,7 +17,7 @@ accesslog_path = Pathname.new(__dir__).join("log/access.log")
|
|
17
17
|
accesslog_path.dirname.mkpath
|
18
18
|
access_logger = ::Logger.new(accesslog_path.to_s)
|
19
19
|
|
20
|
-
#
|
20
|
+
# the target directory on the server's file system
|
21
21
|
DSTDIR = "/var/www/rillbert_se/html/public/giblish_examples/giblish"
|
22
22
|
clone_dir = Dir.mktmpdir
|
23
23
|
|
@@ -42,32 +42,3 @@ end
|
|
42
42
|
get "/" do
|
43
43
|
""
|
44
44
|
end
|
45
|
-
|
46
|
-
# class GenerateDocsFromGitHubHook < Sinatra::Base
|
47
|
-
# ::Logger.class_eval { alias_method :write, :<< }
|
48
|
-
|
49
|
-
# accesslog_path = Pathname.new(__dir__).join("../log/access.log")
|
50
|
-
# accesslog_path.dirname.mkpath
|
51
|
-
# access_logger = ::Logger.new(accesslog_path.to_s)
|
52
|
-
|
53
|
-
# errorlog_path = Pathname.new(__dir__).join("log/error.log")
|
54
|
-
# errorlog_path.dirname.mkpath
|
55
|
-
# error_logger = ::File.new(errorlog_path.to_s, "a+")
|
56
|
-
# error_logger.sync = true
|
57
|
-
|
58
|
-
# configure do
|
59
|
-
# use ::Rack::CommonLogger, access_logger
|
60
|
-
# end
|
61
|
-
|
62
|
-
# before {
|
63
|
-
# env["rack.errors"] = error_logger
|
64
|
-
# }
|
65
|
-
|
66
|
-
# # instantiate the one-and-only web-hook-manager
|
67
|
-
# wm = WebhookManager.new(/svg/, "https://github.com/rillbert/giblish.git", Dir.mktmpdir, "giblish", "docs", dstdir, error_logger)
|
68
|
-
|
69
|
-
# post "/payload" do
|
70
|
-
# gh_data = JSON.parse(request.body.read, symbolized_names: true)
|
71
|
-
# wm.run(gh_data)
|
72
|
-
# end
|
73
|
-
# end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giblish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anders Rillbert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -289,17 +289,18 @@ files:
|
|
289
289
|
- docs/concepts/text_search_im/cgi-search_request.svg
|
290
290
|
- docs/concepts/text_search_im/search_request.puml
|
291
291
|
- docs/concepts/text_search_im/search_request.svg
|
292
|
-
- docs/howtos/
|
293
|
-
- docs/howtos/
|
294
|
-
- docs/howtos/
|
295
|
-
- docs/howtos/
|
296
|
-
- docs/howtos/
|
297
|
-
- docs/howtos/
|
298
|
-
- docs/howtos/
|
299
|
-
- docs/howtos/
|
300
|
-
- docs/howtos/
|
301
|
-
- docs/howtos/
|
292
|
+
- docs/howtos/setup_static_site.adoc
|
293
|
+
- docs/howtos/setup_static_site_assets/Render Documents.png
|
294
|
+
- docs/howtos/setup_static_site_assets/View Documents.png
|
295
|
+
- docs/howtos/setup_static_site_assets/deploy_with_hooks.graphml
|
296
|
+
- docs/howtos/setup_static_site_assets/deploy_with_hooks.svg
|
297
|
+
- docs/howtos/setup_static_site_assets/deploy_with_jenkins.graphml
|
298
|
+
- docs/howtos/setup_static_site_assets/deploy_with_jenkins.svg
|
299
|
+
- docs/howtos/setup_static_site_assets/docgen_github.puml
|
300
|
+
- docs/howtos/setup_static_site_assets/giblish_deployment.graphml
|
301
|
+
- docs/howtos/setup_static_site_assets/post-receive-example.sh
|
302
302
|
- docs/reference/box_flow_spec.adoc
|
303
|
+
- docs/reference/develop_and_build.adoc
|
303
304
|
- docs/reference/search_spec.adoc
|
304
305
|
- exe/giblish
|
305
306
|
- giblish.gemspec
|
@@ -378,11 +379,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
378
379
|
version: '0'
|
379
380
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
380
381
|
requirements:
|
381
|
-
- - "
|
382
|
+
- - ">="
|
382
383
|
- !ruby/object:Gem::Version
|
383
|
-
version:
|
384
|
+
version: '0'
|
384
385
|
requirements: []
|
385
|
-
rubygems_version: 3.3.
|
386
|
+
rubygems_version: 3.3.26
|
386
387
|
signing_key:
|
387
388
|
specification_version: 4
|
388
389
|
summary: A tool for publishing asciidoc docs stored in git repos
|