Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server side fixes #28

Open
wants to merge 244 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
244 commits
Select commit Hold shift + click to select a range
54e3c0e
Fixed OOM issue for all-pairs case
qvad May 8, 2023
3554698
Fixed OOM issue for all-pairs case move to old solution
qvad May 8, 2023
672db29
Add CBO cost estimation vs execution time plot for PG
gauravk-in May 9, 2023
060664a
Fixed small code issues
qvad May 10, 2023
76cf988
Merge pull request #1 from yugabyte/add_pg_plot
qvad May 10, 2023
478c67c
Reworked query plots
qvad May 11, 2023
5270006
Added full path to model option if model name starts with . or /
qvad May 12, 2023
7264ac7
Added debug_hints for query files that will be added inside /*+ ... *…
qvad May 15, 2023
06bb6d4
comma separated queries provided in session-props command line parame…
gauravk-in May 16, 2023
b1f6863
Merge pull request #9 from yugabyte/add_session_props
gauravk-in May 16, 2023
2c117d5
Fixed session props empty query issue
qvad May 17, 2023
00b05db
Reworked diff reporting, not first (red) code will be baseline and (g…
qvad May 19, 2023
94ea070
Configuration report
qvad May 19, 2023
d7be9ae
Merge pull request #11 from yugabyte/configuration-report
qvad May 19, 2023
ae96864
Fixed small typo in score reporting
qvad May 19, 2023
6fd1b75
Extended regression report
qvad May 23, 2023
79cb504
Extended regression report
qvad May 23, 2023
bf72a4d
Fixed code style issue
qvad May 23, 2023
e4984ff
Fixed code style issue 2
qvad May 23, 2023
80aa2cd
Fixed code style issue 3
qvad May 23, 2023
ee8da8b
Merge pull request #13 from yugabyte/extended-reg
qvad May 23, 2023
0c41076
Merge pull request #14 from yugabyte/configuration-report
qvad May 23, 2023
7e86072
Improved score reporting
qvad May 23, 2023
a1c2b03
Minor improvements in score and regression reports
qvad May 23, 2023
4138649
Changed all pairs behaviour, now only leaf nodes are affected (#15)
qvad May 25, 2023
f2b58e5
Added options arguments to change configuraton file values from args.
qvad May 26, 2023
fd159d3
Added python script to import tuned join-order-benchmark data
qvad May 30, 2023
922c455
Fixed all pair threshold logic
qvad Jun 1, 2023
025fc83
Slightely improved table collection code
qvad Jun 1, 2023
143f8d3
Reduced number of tables for all pairs
qvad Jun 1, 2023
a1022a1
Reduced number of tables for all pairs
qvad Jun 1, 2023
2596307
All pairs for scans and joins now triggers on all_pairs_threshold
qvad Jun 1, 2023
653b85b
Added masking password for config toString
qvad Jun 1, 2023
04fd37e
Fixed results parsing code with query tips
qvad Jun 6, 2023
dbdb695
Server side execution (EXPLAIN ANALYZE for PG databases) (#16)
qvad Jun 9, 2023
3152d20
Added more cleanup for YB ANALYZE DIST explain
qvad Jun 9, 2023
cd14850
Merge remote-tracking branch 'origin/main'
qvad Jun 9, 2023
108e4df
Added more cleanup for PG ANALYZE DIST explain
qvad Jun 9, 2023
93bbcd8
Rolled back comments in model queries
qvad Jun 15, 2023
f7d9725
Pg plan parser (#17)
qvad Jun 20, 2023
df5c095
Fixed -inf cost cases and empty PG plans
qvad Jun 22, 2023
9d03f73
Get table row count stats from pg_class.reltuples
mtakahar Jun 3, 2023
f23bad3
Merge pull request #18 from yugabyte/mtakahara_table_row_count
mtakahar Jun 22, 2023
3365e34
Tuned regression report for no v2 optimizations case (#20)
qvad Jun 30, 2023
aa2ee53
Delete accidentally checked in .DS_Store; add .gitignore rules for ma…
mtakahar Jun 30, 2023
706e110
Fixed typos in regression
qvad Jul 4, 2023
f386f99
Fixed ratios
qvad Jul 4, 2023
97513e5
Tuned regression reporting summary tables
qvad Jul 5, 2023
f510e3b
Regression v2 best now equals v1 best if v2 has no optimizations
qvad Jul 5, 2023
371732b
New parser implementation (#19)
qvad Jul 6, 2023
c75efa6
Copy the "rows" field in Table.copy() (#22)
mtakahar Jul 7, 2023
7e277e6
Fixed look near best plan behaviour
qvad Jul 7, 2023
eb9dbcf
Fixed regression report issue with wrong geometric metrics values
qvad Jul 9, 2023
ed375df
Fixed execution plan duplication check fails due to timeout
qvad Jul 9, 2023
b2d86bc
Fixed all scans case optimization generation (WIP)
qvad Jul 9, 2023
dc927ca
Fixed subqueries alias names
qvad Jul 10, 2023
9a6b68d
Code refactoring changes
qvad Jul 10, 2023
2063a49
Fixed reporting of parametrized queries
qvad Jul 10, 2023
031429f
Fixed optimizations generator
qvad Jul 10, 2023
b2de31c
Fixed star querying case
qvad Jul 10, 2023
2ac3b8d
Add more columns to regress xls report
mtakahar Jul 10, 2023
c9898a7
Merge pull request #23 from yugabyte/mtakahara_regress_xls
mtakahar Jul 10, 2023
cac450d
Rolled back look_near_best_plan behaviour to limit max execution time.
qvad Jul 11, 2023
c5f2553
Store PlanNode properties as {key: value} pairs instead of [str]
mtakahar Jun 22, 2023
fcccbde
Save more column metadata to .json file
mtakahar Jul 12, 2023
666de5c
Merge pull request #24 from yugabyte/mtakahara_collect_more_column_me…
mtakahar Jul 13, 2023
c318d30
Small change in score report to show YB Best/Default equality
qvad Jul 14, 2023
ce51af7
Fixed postgres missing timeout query definition
qvad Jul 17, 2023
144b40e
Added all-index-check skip for join-order-benchmark
qvad Jul 18, 2023
146e7e0
fix single result (no PG) taqo report (#25)
mtakahar Jul 21, 2023
0f578b4
clean up Plan/ScanNode creation and add node property accessors
mtakahar Jul 14, 2023
c6ef025
wip: add experimental "cost" report type for cost validation charts
mtakahar Jul 21, 2023
8a4ce94
Merge pull request #27 from yugabyte/mtakahara_cost-validation-report
mtakahar Jul 27, 2023
720e988
Postgres unit test generator for collect step (#26)
qvad Jul 31, 2023
6d95a7c
Fixed plan comparison issue related to Sort Method stats
qvad Jul 31, 2023
054053b
Fixed plan comparison issue related to Sort Method stats
qvad Jul 31, 2023
6bb68f1
Fixed plan comparison for regression report
qvad Jul 31, 2023
f5d741d
Added eq flag if v1.default == v2.default
qvad Jul 31, 2023
b421206
Fixed pgunit report generation issue
qvad Aug 2, 2023
577a4b5
Interactive chart generated using bokeh
gauravk-in Aug 2, 2023
9590e53
Added exception in case of asciidoctor is not available
qvad Aug 3, 2023
39adbba
add cost report interactive chart mode
mtakahar Aug 1, 2023
a5b9e07
Merge pull request #28 from yugabyte/mtakahara_cost-validation-report
mtakahar Aug 3, 2023
b207740
Interactive chart generated using bokeh
gauravk-in Aug 2, 2023
4fabdb9
Added linked graphs to html
gauravk-in Aug 3, 2023
b350be7
Scale graphs to window size
gauravk-in Aug 3, 2023
2a8734c
Fix typo
gauravk-in Aug 3, 2023
58619a7
Separating the toolbox for the graphs
gauravk-in Aug 3, 2023
132cf1e
Color coding queries from different SQL files
gauravk-in Aug 3, 2023
0ea1cf5
Highlight queries with bad plans with red outline
gauravk-in Aug 4, 2023
ba0b5f8
Refactor
gauravk-in Aug 4, 2023
36343f0
Change color palette
gauravk-in Aug 7, 2023
2992d00
Add interactive legend: hide points from different files
gauravk-in Aug 7, 2023
2b976b8
Remove unnecessary imports
gauravk-in Aug 7, 2023
16b8757
Merge pull request #29 from yugabyte/interactive_charts
gauravk-in Aug 7, 2023
416bc20
Comments, minor fixes, hide bad queries from legend, highlight select…
gauravk-in Aug 7, 2023
270ea06
cost report: fix error processing results produced with EXPLAIN VERBOSE
mtakahar Aug 3, 2023
7239990
Merge pull request #32 from yugabyte/mtakahara_cost-validation-report
mtakahar Aug 7, 2023
4838616
stop using re pattern '?>' that is not supported in Python 3.10-
mtakahar Aug 8, 2023
17442c6
Merge pull request #33 from yugabyte/mtakahara-no-py311-re
mtakahar Aug 8, 2023
c941edb
Maintain TAQO - removed DESC from basic and fixed small issue in pg_u…
qvad Aug 9, 2023
6a79fc6
Removed stats.sql files
qvad Aug 15, 2023
1943c11
Fixed execution plan collection placing - now it is collected after w…
qvad Aug 16, 2023
d5cd053
Fixed query timeout issue
qvad Aug 18, 2023
3854712
Fixed negative min timeout issue
qvad Aug 18, 2023
3eebdef
Fixed in reporting to avoid counting failed optimizations
qvad Aug 19, 2023
cc4580c
Fix in execution plan collecting code in case of query timed out
qvad Aug 22, 2023
1f4331f
Fixes and enhancements to PlanNode and cost report (#36)
mtakahar Aug 28, 2023
b7b6562
Add distribution charts to cost report; exclude and report extreme ou…
mtakahar Aug 30, 2023
12842c0
Fixed alias to alias issue
qvad Sep 5, 2023
da21d8d
Fixed tqdm usage
qvad Sep 6, 2023
5a6055d
(TBD) Quickfix for unit files generation
qvad Sep 7, 2023
710a254
Increased default execution timeout to 40 minutes.
qvad Sep 7, 2023
488dec4
Tuned configuration and failed query output
qvad Sep 12, 2023
a4444b8
Compact tables and execution improvements (#35)
qvad Sep 12, 2023
fecb74d
Improved test database management in compaction retries
qvad Sep 12, 2023
6a41a07
Query timeout option for model config and added result printing for c…
qvad Sep 12, 2023
5519690
cost report: log and skip queries without any valid plan (#39)
mtakahar Sep 13, 2023
7a43dd6
Exception hadnling for compaction check_output calls
qvad Sep 15, 2023
c7c3612
Merge remote-tracking branch 'origin/main'
qvad Sep 15, 2023
9c28208
Increased waiting time for compaction
qvad Sep 15, 2023
070a505
Moved compaction timeout to config and model config
qvad Sep 15, 2023
052a653
cost report: EXPLAIN VERBOSE handling and outlier detection improveme…
mtakahar Sep 15, 2023
39d988e
Fixed negative execution time issue (#41)
qvad Sep 19, 2023
7fae1fd
Fixed best optimization finding issue
qvad Sep 20, 2023
6edafaa
Fixed master address issue
qvad Sep 21, 2023
5a62a05
Fixed master address issue
qvad Sep 25, 2023
0110525
Fixed master address issue
qvad Sep 26, 2023
8ce0155
cost report enhancements and clean up (#43)
mtakahar Sep 27, 2023
5f58bcc
Fixed clint side execution time collecting
qvad Sep 27, 2023
90f6aca
Merge remote-tracking branch 'origin/main'
qvad Sep 27, 2023
4ba7f2b
Tuned execution time collecting step
qvad Sep 27, 2023
39054b3
add column count/position, value position charts to cost report
mtakahar Sep 28, 2023
cb6a439
Split score reports to a small subreports (#42)
qvad Oct 3, 2023
72e4369
split off cost chart specs from cost.py
mtakahar Oct 3, 2023
4eb0732
Fixed small issue with double query preparation
qvad Oct 5, 2023
714a717
Increased default temp_file_limit to support job workload
qvad Oct 5, 2023
87fa936
Fix tap event in bokeh charts
gauravk-in Oct 5, 2023
e3f1819
Added Geometric mean QE default to score report
qvad Oct 9, 2023
af88ff9
Added Geometric mean QE default to score report FIX
qvad Oct 9, 2023
0975852
Added Geometric mean QE default to score report FIX
qvad Oct 9, 2023
40b706a
split cost report into multiple html files
mtakahar Oct 4, 2023
7d0c556
show data point and extreme outlier counts on the cost report top pag…
mtakahar Oct 10, 2023
9c2a745
Update bokeh version
gauravk-in Oct 18, 2023
9209bc6
skip flushing and compacting system catalog tables; polish up README
yifanguan Oct 24, 2023
ba3eab2
use flush_sys_catalog and compact_sys_catalog for system catalogs
yifanguan Oct 24, 2023
0de7e54
temp workaround for many flush and compaction for colocated tables
yifanguan Oct 24, 2023
7f8f2ee
remove temp workaround; ready for review
yifanguan Oct 25, 2023
4df8bb0
Merge pull request #48 from yugabyte/skip_flush_compaction_for_catalo…
yifanguan Oct 25, 2023
b8e2415
add query plan subreports to cost report
mtakahar Oct 11, 2023
f890c42
Fix regression test output (#52)
gauravk-in Nov 2, 2023
aef8028
Compact only one table if compaction enabled (#53)
qvad Nov 3, 2023
063e052
Fixed select star case - collected all tables and fields in this case
qvad Nov 3, 2023
7a1f4ec
Add basic cost metric report
mtakahar Oct 31, 2023
e39351f
Non colocated database now use different name by default
qvad Nov 7, 2023
e7832b8
Non colocated database now use different name by default FIX
qvad Nov 7, 2023
e6fcb4d
Handle exception in linregress
gauravk-in Nov 20, 2023
b84eeb6
SET queries are used as debug ones in model query files (#55)
qvad Nov 27, 2023
9804d55
Changing DDL to ASC explicitly (#56)
qvad Dec 12, 2023
68f74b4
Fixed join-order-benchmark index creation for YB
qvad Dec 21, 2023
7884cd6
Fixed join-order-benchmark index creation for YB
qvad Dec 21, 2023
368ba07
Removed --enable-statistics flag - use --session-props to define yb_e…
qvad Jan 5, 2024
31a5b3f
Removed --enable-statistics flag - use --session-props to define yb_e…
qvad Jan 5, 2024
89e5571
Removed --enable-statistics flag - use --session-props to define yb_e…
qvad Jan 5, 2024
9c7e2c5
Removed --enable-statistics flag - use --session-props to define yb_e…
qvad Jan 5, 2024
fd4d74b
Refactored code around DDL command execution (#57)
qvad Jan 9, 2024
c7ba738
Fixed copy case (#59)
qvad Jan 10, 2024
2e6b83b
Added result validation during execution (#58)
qvad Feb 2, 2024
1d70592
Exit on fail improvement
qvad Feb 6, 2024
c626ca8
Fixed now() queries result validation
qvad Feb 6, 2024
2b2affc
Improved exit codes and added warnings in case of difference in execu…
qvad Feb 12, 2024
5318ce2
Fixed LIMIT without ORDER BY case
qvad Feb 12, 2024
3131bd4
Fixed score report
qvad Feb 12, 2024
e37236c
Fixed warning about analyze time
qvad Feb 16, 2024
4f775b6
Fixed analyze warning score report
qvad Feb 16, 2024
2ffe45f
Fixed analyze warning score report
qvad Feb 16, 2024
ac09e79
Added JSON score mini-report
qvad Feb 26, 2024
eb6bb01
Fixed dat generation code
qvad Mar 4, 2024
cc49839
Proper YB version detection (#61)
qvad Mar 4, 2024
c7386cc
Added UNSTABLE mark for errors
qvad Mar 5, 2024
1c36eee
Added skip_consistency_check tag
qvad Mar 6, 2024
90e89da
Added skip_consistency_check to subqueries model
qvad Mar 6, 2024
fd5841d
Small improvements in stats report
qvad Mar 12, 2024
867b584
Added hash for job, subqueries, complex
qvad Mar 12, 2024
7c9f7d6
Split regression report by tags (#63)
qvad Apr 1, 2024
f9adb8c
Fixed PG version detection
qvad Apr 3, 2024
57994c6
Merge remote-tracking branch 'origin/main'
qvad Apr 3, 2024
659eb07
Fixed stats report to return error
qvad Apr 3, 2024
eee42db
Fixed empty optimizations
qvad Apr 3, 2024
abcf90e
Added drop database after test
qvad Apr 10, 2024
c9c3c99
Tuned connection close and db drop code
qvad Apr 10, 2024
cf3a48c
Fixed execution time extraction code after changes in result validation
qvad Apr 21, 2024
07a1420
Added total DDL time and model time to stats report
qvad Apr 22, 2024
27e0e35
Debug logging on QueryCancelled
qvad Apr 23, 2024
3b16c02
Fixed geo_mean calculation
qvad Apr 23, 2024
d70037a
Fixed no PG query issue
qvad Apr 23, 2024
8755318
Fixed GE overflow issue
qvad Apr 23, 2024
704f946
Added flag to disabled YB stats
qvad Apr 23, 2024
6742ec8
Fixed reset stats case
qvad Apr 23, 2024
1862edb
Optimized plan comparison (#64)
qvad Apr 25, 2024
4e5ac24
Improved reporting plan comparison
qvad Apr 25, 2024
c17ed6c
Improved reporting plan comparison (Part 2)
qvad Apr 25, 2024
7caee66
Fixed cost_off comparison logic
qvad Apr 29, 2024
f48a0e8
Fixed cost_off comparison logic for PG queries
qvad Apr 29, 2024
583993d
Enabled bitmap scans and BNLJ
qvad May 1, 2024
e58aab9
Collect current gflags for YB databases (#65)
qvad May 6, 2024
a44f857
Disabled bitmap scan tip until release
qvad May 6, 2024
e3ca3ff
Fixe regression report incompatible models
qvad May 8, 2024
a6870bd
Added proper error reporting in case of exit_on_fail is disabled
qvad May 8, 2024
7e5f1e6
Added order by detection (#66)
qvad May 10, 2024
f12e1d2
Optimization now has original query value
qvad May 10, 2024
dc027aa
Added bitmap scans as flags
qvad May 14, 2024
7ab8930
Does not compare results if original query is timed out
qvad May 31, 2024
7e29a3a
Added TPCH (#67)
qvad Jun 5, 2024
c0d2347
Fixed TPCH queries
qvad Jun 6, 2024
137d3b9
Fixes in reporting
qvad Jun 7, 2024
b73c6d5
Fixed score stats ports
qvad Jun 7, 2024
a3eed3f
Added more stats for regression report
qvad Jun 7, 2024
a813ba0
Added more stats for regression report, fixed same plans
qvad Jun 7, 2024
883458e
Added hash for TPCH (#68)
qvad Jun 17, 2024
dcde72a
Added allowed diff for regression report
qvad Jun 18, 2024
bf7c7cc
Added copy to a clipboard button for query view (#69)
qvad Jun 26, 2024
d58a12d
Temporary fix for RPC timeout issue
qvad Jul 2, 2024
147e8fb
Merge remote-tracking branch 'origin/main'
qvad Jul 2, 2024
5ac9e4a
Failed error detection in Jenkins
qvad Jul 10, 2024
4869075
Added w/o for GH21041
qvad Jul 12, 2024
39fbe73
Force warning in case of failed to collect statistics
qvad Jul 15, 2024
9d3908b
Mute query statistics exceptions
qvad Jul 15, 2024
bb3e1b9
Fixed
qvad Jul 15, 2024
8981fa0
Fixed analyze warnings
qvad Jul 15, 2024
533c034
Ratio color fix
qvad Jul 16, 2024
9c2af97
Ratio color fix
qvad Jul 16, 2024
08c5d5b
Statistics regression fix
qvad Jul 16, 2024
f8b7aa1
Fixed score stats missing queries count
qvad Jul 16, 2024
9b58a15
Fixed default for clean-db
qvad Jul 25, 2024
800c310
Add plans to .xls
mtakahar Jul 29, 2024
79a3763
Added more rollback tries
qvad Sep 10, 2024
b8dea9d
Merge remote-tracking branch 'origin/main'
qvad Sep 10, 2024
b715953
Fixed DDL query detection
qvad Nov 12, 2024
b4e88d8
Added WIP server execution time and removed hints
qvad Dec 6, 2024
5c76b49
Reduced percentage delta to 5%
qvad Dec 6, 2024
0a52a7e
Fix for bokeh library usage (#71)
qvad Dec 9, 2024
251cf4d
Reduced percentage delta
qvad Dec 9, 2024
26fdd17
Fix incorrect time issue in server-side-execution and inconsisten res…
gauravk-in Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ report/

sql/proprietary/

# macOS specific
.DS_Store
*.dylib

# GitHub generated ignores
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ substrings of `pg_hints`can be mentioned there:
-- accept: a b c
-- reject: NestLoop
-- max_timeout: 5s
-- tags: muted_nlj, 5s_max
-- tags: muted_nlj, 5s_max, skip_consistency_check
-- debug_hints: set (yb_enable_optimizer_statistics false)

select a.c1,
a.c2, ...
Expand All @@ -177,6 +178,12 @@ After optimizations are generated, the framework evaluates all of them with maxi
equal to current minimum execution time (starts with original optimization timeout) so do not spend
time on worst cases.

#### Result validation

TAQO implements consistency checks, which are reflected in the collect and report logs.
In the event that certain optimizations yield varying results, these discrepancies will be brought to attention.
To disable this feature, you can add the skip_consistency_check tag.

----

## Report
Expand Down Expand Up @@ -251,7 +258,7 @@ session-props = [
skip-percentage-delta = 0.15

# query execution related options
ddl-query-timeout = 3600 # skip DDL if they evaluated in more than 1200 seconds
ddl-query-timeout = 3600 # skip DDL if they evaluated in more than 3600 seconds
test-query-timeout = 1200 # skip queries if they evaluated in more than 1200 seconds

# optimization generation
Expand Down Expand Up @@ -333,8 +340,6 @@ options:
--username USERNAME Username for connection
--password PASSWORD Password for user for connection
--database DATABASE Target database in postgres compatible database
--enable-statistics, --no-enable-statistics
Evaluate yb_enable_optimizer_statistics before running queries (default: False)
--explain-clause EXPLAIN_CLAUSE
Explain clause that will be placed before query. Default "EXPLAIN"
--num-queries NUM_QUERIES
Expand All @@ -355,19 +360,19 @@ See prepared scenarios in `bin/` directory
Collect queries results for basic model for localhost cluster

```
src/runner.py
python3 src/runner.py
collect
--optimizations
--model=basic
--config=config/qo.conf
--output=taqo_complex_yb
--config=config/default.conf
--output=taqo_basic_yb
--database=taqo
```

Generate comparison report for 2 previous collect runs

```
src/runner.py
python3 src/runner.py
report
--type=regression
--config=config/qo.conf
Expand All @@ -378,10 +383,10 @@ report
Generate score report which contains taqo analysis and comparison with postgres

```
src/runner.py
python3 src/runner.py
report
--type=score
--config=config/qo.conf
--results=report/basic_taqo_yb.json
--pg-results=report/basic_taqo_pg.json
```
```
10 changes: 9 additions & 1 deletion css/adoc.css → adoc/adoc.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
/* Based on Cosmo from Bootswatch (https://bootswatch.com/cosmo/) */
@import url("//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700");

/* table cell alignment attribute definitions from Asciidoctor default css */
th.halign-left,td.halign-left{text-align:left}
th.halign-right,td.halign-right{text-align:right}
th.halign-center,td.halign-center{text-align:center}
th.valign-top,td.valign-top{vertical-align:top}
th.valign-bottom,td.valign-bottom{vertical-align:bottom}
th.valign-middle,td.valign-middle{vertical-align:middle}

/* document body (contains all content) */
body {
font-family: "Source Sans Pro", Calibri, Candara, Arial, sans-serif;
Expand Down Expand Up @@ -356,4 +364,4 @@ video {
.black {color: #000000}
.red {color: #911717}
.blue {color: #3a3aac}
.green {color:#080}
.green {color:#080}
7 changes: 7 additions & 0 deletions adoc/copy-to-clipboard-docinfo-processor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RUBY_ENGINE == 'opal' ? (require 'copy-to-clipboard-docinfo-processor/extension') : (require_relative 'copy-to-clipboard-docinfo-processor/extension')

Asciidoctor::Extensions.register do
tree_processor CopyToClipboardTreeProcessor
docinfo_processor CopyToClipboardStylesDocinfoProcessor
docinfo_processor CopyToClipboardBehaviorDocinfoProcessor
end
83 changes: 83 additions & 0 deletions adoc/copy-to-clipboard-docinfo-processor/behavior.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*! https://gitlab.com/antora/antora-ui-default/-/blob/master/src/js/06-copy-to-clipboard.js | License: MPL-2.0 */
;(function () {
'use strict'

var CMD_RX = /^\$ (\S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*)(?=\n|$)/gm
var LINE_CONTINUATION_RX = /( ) *\\\n *|\\\n( ?) */g
var TRAILING_SPACE_RX = / +$/gm
var LEADING_SPACE_NUMBER_RX = /^ ?\d+/gm;

var config = (document.getElementById('site-script') || { dataset: {} }).dataset
var supportsCopy = window.navigator.clipboard
var svgAs = config.svgAs
var uiRootPath = (config.uiRootPath == null ? window.uiRootPath : config.uiRootPath) || '.'

;[].slice.call(document.querySelectorAll('.doc pre.highlight, .doc .literalblock pre')).forEach(function (pre) {
var code, language, lang, copy, toast, toolbox
if (pre.classList.contains('highlight')) {
code = pre.querySelector('code')
if ((language = code.dataset.lang) && language !== 'console') {
;(lang = document.createElement('span')).className = 'source-lang'
lang.appendChild(document.createTextNode(language))
}
} else if (pre.innerText.startsWith('$ ')) {
var block = pre.parentNode.parentNode
block.classList.remove('literalblock')
block.classList.add('listingblock')
pre.classList.add('highlightjs', 'highlight')
;(code = document.createElement('code')).className = 'language-console hljs'
code.dataset.lang = 'console'
code.appendChild(pre.firstChild)
pre.appendChild(code)
} else {
return
}
;(toolbox = document.createElement('div')).className = 'source-toolbox'
if (lang) toolbox.appendChild(lang)
// TODO not the best solution?
// if (supportsCopy) {
;(copy = document.createElement('button')).className = 'copy-button'
copy.setAttribute('title', 'Copy to clipboard')
if (svgAs === 'svg') {
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.setAttribute('class', 'copy-icon')
var use = document.createElementNS('http://www.w3.org/2000/svg', 'use')
use.setAttribute('href', uiRootPath + '/img/octicons-16.svg#icon-clippy')
svg.appendChild(use)
copy.appendChild(svg)
} else {
var img = document.createElement('img')
img.src = uiRootPath + '/img/octicons-16.svg#view-clippy'
img.alt = 'copy icon'
img.className = 'copy-icon'
copy.appendChild(img)
}
;(toast = document.createElement('span')).className = 'copy-toast'
toast.appendChild(document.createTextNode('Copied!'))
copy.appendChild(toast)
toolbox.appendChild(copy)
// }
pre.parentNode.appendChild(toolbox)
if (copy) copy.addEventListener('click', writeToClipboard.bind(copy, code))
})

function extractCommands (text) {
var cmds = []
var m
while ((m = CMD_RX.exec(text))) cmds.push(m[1].replace(LINE_CONTINUATION_RX, '$1$2'))
return cmds.join(' && ')
}

function writeToClipboard (code) {
var text = code.innerText.replace(TRAILING_SPACE_RX, '').replace(/''/g, "'").replace(LEADING_SPACE_NUMBER_RX, '')
if (code.dataset.lang === 'console' && text.startsWith('$ ')) text = extractCommands(text)
window.navigator.clipboard.writeText(text).then(
function () {
this.classList.add('clicked')
this.offsetHeight // eslint-disable-line no-unused-expressions
this.classList.remove('clicked')
}.bind(this),
function () {}
)
}
})()
34 changes: 34 additions & 0 deletions adoc/copy-to-clipboard-docinfo-processor/extension.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class CopyToClipboardTreeProcessor < Asciidoctor::Extensions::TreeProcessor
def process doc
doc.add_role 'doc' unless doc.has_role? 'doc'
nil
end
end

class CopyToClipboardStylesDocinfoProcessor < Asciidoctor::Extensions::DocinfoProcessor
use_dsl
at_location :head

def process doc
extdir = ::File.join ::File.dirname __FILE__
<<-EOS
<style>
#{doc.read_asset %(#{extdir}/styles.css)}
</style>
EOS
end
end

class CopyToClipboardBehaviorDocinfoProcessor < Asciidoctor::Extensions::DocinfoProcessor
use_dsl
at_location :footer

def process doc
extdir = ::File.join ::File.dirname __FILE__
<<-EOS
<script id="site-script">
#{doc.read_asset %(#{extdir}/behavior.js)}
</script>
EOS
end
end
36 changes: 36 additions & 0 deletions adoc/copy-to-clipboard-docinfo-processor/img/octicons-16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions adoc/copy-to-clipboard-docinfo-processor/sample.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
= Sample
:source-highlighter: highlight.js

[,ruby]
----
Asciidoctor::Extensions.register do
block do
named :sample
on_context :open

process do |parent, reader, attrs|
create_paragraph parent, reader.lines, attrs
end
end
end
----
92 changes: 92 additions & 0 deletions adoc/copy-to-clipboard-docinfo-processor/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*! derived from https://gitlab.com/antora/antora-ui-default/-/blob/master/src/css/doc.css | License: MPL-2.0 */
.doc .listingblock > .content {
position: relative;
}

.doc .listingblock code[data-lang]::before {
content: none;
}

.doc .source-toolbox {
display: flex;
position: absolute;
visibility: hidden;
top: 0.25rem;
right: 0.5rem;
color: #808080;
white-space: nowrap;
font-size: 0.85em;
}

.doc .listingblock:hover .source-toolbox {
visibility: visible;
}

.doc .source-toolbox .source-lang {
font-family: "Droid Sans Mono", "DejaVu Sans Mono", monospace;
text-transform: uppercase;
letter-spacing: 0.075em;
}

.doc .source-toolbox > :not(:last-child)::after {
content: "|";
letter-spacing: 0;
padding: 0 1ch;
}

.doc .source-toolbox .copy-button {
cursor: pointer;
display: flex;
flex-direction: column;
align-items: center;
background: none;
border: none;
color: inherit;
outline: none;
padding: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
width: 1em;
height: 1em;
}

.doc .source-toolbox .copy-icon {
flex: none;
width: inherit;
height: inherit;
filter: invert(50.2%);
margin-top: 0.05em;
}

.doc .source-toolbox .copy-toast {
flex: none;
position: relative;
display: inline-flex;
justify-content: center;
margin-top: 1em;
border-radius: 0.25em;
padding: 0.5em;
cursor: auto;
opacity: 0;
transition: opacity 0.5s ease 0.75s;
background: rgba(0, 0, 0, 0.8);
color: #fff;
}

.doc .source-toolbox .copy-toast::after {
content: "";
position: absolute;
top: 0;
width: 1em;
height: 1em;
border: 0.55em solid transparent;
border-left-color: rgba(0, 0, 0, 0.8);
transform: rotate(-90deg) translateX(50%) translateY(50%);
transform-origin: left;
}

.doc .source-toolbox .copy-button.clicked .copy-toast {
opacity: 1;
transition: none;
}
Loading