diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-04 18:10:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-04 18:10:24 +0300 |
commit | 07516504537bef518a3f80b60ebca761209feab5 (patch) | |
tree | 57130bbff016e2b2443c1a01273662469763c411 /vendor | |
parent | 46b08e61d27f9b3f45b130f9204084ffcf50c304 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'vendor')
22 files changed, 44 insertions, 61 deletions
diff --git a/vendor/gems/ipynbdiff/lib/output_transformer.rb b/vendor/gems/ipynbdiff/lib/output_transformer.rb index 88728df2f17..e7adfbd8c3e 100644 --- a/vendor/gems/ipynbdiff/lib/output_transformer.rb +++ b/vendor/gems/ipynbdiff/lib/output_transformer.rb @@ -19,25 +19,14 @@ module IpynbDiff end def transform(output, symbol) - transformed = case (output_type = output['output_type']) - when 'error' - transform_error(output['traceback'], symbol / 'traceback') - when 'execute_result', 'display_data' - transform_non_error(ORDERED_KEYS[output_type], output['data'], symbol / 'data') - when 'stream' - transform_element('text', output['text'], symbol) - end - - transformed ? decorate_output(transformed, output, symbol) : [] - end - - def decorate_output(output_rows, output, symbol) - [ - _, - _(symbol, %(%%%% Output: #{output['output_type']})), - _, - *output_rows - ] + case (output_type = output['output_type']) + when 'error' + transform_error(output['traceback'], symbol / 'traceback') + when 'execute_result', 'display_data' + transform_non_error(ORDERED_KEYS[output_type], output['data'], symbol / 'data') + when 'stream' + transform_element('text', output['text'], symbol) + end end def transform_error(traceback, symbol) diff --git a/vendor/gems/ipynbdiff/lib/transformer.rb b/vendor/gems/ipynbdiff/lib/transformer.rb index 153d821db27..64d59eeaea8 100644 --- a/vendor/gems/ipynbdiff/lib/transformer.rb +++ b/vendor/gems/ipynbdiff/lib/transformer.rb @@ -20,7 +20,7 @@ module IpynbDiff def initialize(include_frontmatter: true, hide_images: false) @include_frontmatter = include_frontmatter @hide_images = hide_images - @output_transformer = OutputTransformer.new(hide_images: hide_images) + @out_transformer = OutputTransformer.new(hide_images: hide_images) end def validate_notebook(notebook) @@ -75,9 +75,19 @@ module IpynbDiff _(symbol / 'source', %(``` #{notebook.dig('metadata', 'kernelspec', 'language') || ''})), symbolize_array(symbol / 'source', cell['source'], &:rstrip), _(nil, '```'), - cell['outputs'].map.with_index do |output, idx| - @output_transformer.transform(output, symbol / ['outputs', idx]) - end + transform_outputs(cell['outputs'], symbol) + ] + end + + def transform_outputs(outputs, symbol) + transformed = outputs.map + .with_index { |output, i| @out_transformer.transform(output, symbol / ['outputs', i]) } + .compact + .map { |el| [_, el] } + + [ + transformed.empty? ? [] : [_, _(symbol / 'outputs', '%% Output')], + transformed ] end diff --git a/vendor/gems/ipynbdiff/spec/testdata/error_output/expected.md b/vendor/gems/ipynbdiff/spec/testdata/error_output/expected.md index 5be645de9c9..e6e8a075598 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/error_output/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/error_output/expected.md @@ -5,7 +5,7 @@ y = sin(x) ``` -%%%% Output: error +%% Output --------------------------------------------------------------------------- NameError Traceback (most recent call last) diff --git a/vendor/gems/ipynbdiff/spec/testdata/error_output/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/error_output/expected_symbols.txt index 75e35d123d0..5d2f248135d 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/error_output/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/error_output/expected_symbols.txt @@ -5,7 +5,7 @@ .cells.0.source.1 -.cells.0.outputs.0 +.cells.0.outputs .cells.0.outputs.0.traceback.0 .cells.0.outputs.0.traceback.1 diff --git a/vendor/gems/ipynbdiff/spec/testdata/hide_images/expected.md b/vendor/gems/ipynbdiff/spec/testdata/hide_images/expected.md index 89a812740a6..ff63d351a3b 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/hide_images/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/hide_images/expected.md @@ -3,10 +3,8 @@ ``` python ``` -%%%% Output: display_data +%% Output [Hidden Image Output] -%%%% Output: display_data - [Hidden Image Output] diff --git a/vendor/gems/ipynbdiff/spec/testdata/hide_images/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/hide_images/expected_symbols.txt index b94e9538f58..b8f24f9fba5 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/hide_images/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/hide_images/expected_symbols.txt @@ -3,10 +3,8 @@ .cells.0.source -.cells.0.outputs.0 +.cells.0.outputs -.cells.0.outputs.1 - diff --git a/vendor/gems/ipynbdiff/spec/testdata/ignore_html_output/expected.md b/vendor/gems/ipynbdiff/spec/testdata/ignore_html_output/expected.md index 456224f3aff..3085da739ed 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/ignore_html_output/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/ignore_html_output/expected.md @@ -4,7 +4,7 @@ df[:2] ``` -%%%% Output: execute_result +%% Output x y 0 0.000000 0.000000 diff --git a/vendor/gems/ipynbdiff/spec/testdata/ignore_html_output/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/ignore_html_output/expected_symbols.txt index fa9d412c6dc..3bf319d1fa6 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/ignore_html_output/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/ignore_html_output/expected_symbols.txt @@ -4,7 +4,7 @@ .cells.0.source.0 -.cells.0.outputs.0 +.cells.0.outputs .cells.0.outputs.0.data.text/plain.0 .cells.0.outputs.0.data.text/plain.1 diff --git a/vendor/gems/ipynbdiff/spec/testdata/latex_output/expected.md b/vendor/gems/ipynbdiff/spec/testdata/latex_output/expected.md index add84ed26a0..194c1f43c42 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/latex_output/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/latex_output/expected.md @@ -5,6 +5,6 @@ from IPython.display import display, Math display(Math(r'Dims: {}x{}m \\ Area: {}m^2 \\ Volume: {}m^3'.format(1, round(2,2), 3, 4))) ``` -%%%% Output: display_data +%% Output $\displaystyle Dims: 1x2m \\ Area: 3m^2 \\ Volume: 4m^3$ diff --git a/vendor/gems/ipynbdiff/spec/testdata/latex_output/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/latex_output/expected_symbols.txt index 9407e6db702..868adca2712 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/latex_output/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/latex_output/expected_symbols.txt @@ -5,6 +5,6 @@ .cells.0.source.1 -.cells.0.outputs.0 +.cells.0.outputs .cells.0.outputs.0.data.text/latex.0 diff --git a/vendor/gems/ipynbdiff/spec/testdata/multiline_png_output/expected.md b/vendor/gems/ipynbdiff/spec/testdata/multiline_png_output/expected.md index 4a880d8ce18..0a69c8370e7 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/multiline_png_output/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/multiline_png_output/expected.md @@ -4,6 +4,6 @@ Some Image ``` -%%%% Output: display_data +%% Output ![](data:image/png;base64,this_is_an_invalid_hash_for_testing_purposes) diff --git a/vendor/gems/ipynbdiff/spec/testdata/multiline_png_output/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/multiline_png_output/expected_symbols.txt index 26e11781ec1..1b66012ef20 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/multiline_png_output/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/multiline_png_output/expected_symbols.txt @@ -4,6 +4,6 @@ .cells.0.source.0 -.cells.0.outputs.0 +.cells.0.outputs .cells.0.outputs.0.data.image/png diff --git a/vendor/gems/ipynbdiff/spec/testdata/percent_decorator/expected.md b/vendor/gems/ipynbdiff/spec/testdata/percent_decorator/expected.md index ecb0029f256..1ece1f2fd06 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/percent_decorator/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/percent_decorator/expected.md @@ -38,12 +38,10 @@ y = np.sin(x) plt.plot(x, y) ``` -%%%% Output: execute_result +%% Output [<matplotlib.lines.Line2D at 0x123e39370>] -%%%% Output: display_data - ![](data:image/png;base64,some_invalid_base64_image_here) %% Cell type:code id:dc1178cd-c46d-4da3-9ab5-08f000699884 tags: @@ -58,7 +56,7 @@ df = pd.DataFrame({"x": x, "y": y}) df[:2] ``` -%%%% Output: execute_result +%% Output x y 0 0.000000 0.000000 diff --git a/vendor/gems/ipynbdiff/spec/testdata/percent_decorator/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/percent_decorator/expected_symbols.txt index ab70e7bc908..c95665d1903 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/percent_decorator/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/percent_decorator/expected_symbols.txt @@ -38,12 +38,10 @@ .cells.4.source.3 -.cells.4.outputs.0 +.cells.4.outputs .cells.4.outputs.0.data.text/plain.0 -.cells.4.outputs.1 - .cells.4.outputs.1.data.image/png .cells.5 @@ -58,7 +56,7 @@ .cells.6.source.0 -.cells.6.outputs.0 +.cells.6.outputs .cells.6.outputs.0.data.text/plain.0 .cells.6.outputs.0.data.text/plain.1 diff --git a/vendor/gems/ipynbdiff/spec/testdata/stream_text/expected.md b/vendor/gems/ipynbdiff/spec/testdata/stream_text/expected.md index fb862cbb636..0448bf21111 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/stream_text/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/stream_text/expected.md @@ -4,6 +4,6 @@ print("G'bye") ``` -%%%% Output: stream +%% Output G'bye diff --git a/vendor/gems/ipynbdiff/spec/testdata/stream_text/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/stream_text/expected_symbols.txt index ed4a8a075d3..be4e2861ea9 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/stream_text/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/stream_text/expected_symbols.txt @@ -4,6 +4,6 @@ .cells.0.source.0 -.cells.0.outputs.0 +.cells.0.outputs .cells.0.outputs.0.text.0 diff --git a/vendor/gems/ipynbdiff/spec/testdata/svg/expected.md b/vendor/gems/ipynbdiff/spec/testdata/svg/expected.md index 37269446f5a..a5a167d31c5 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/svg/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/svg/expected.md @@ -10,10 +10,8 @@ svg = """<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> display(SVG(svg)) ``` -%%%% Output: display_data +%% Output ![](data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="50"/></svg>) -%%%% Output: display_data - ![](data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="50"/></svg>) diff --git a/vendor/gems/ipynbdiff/spec/testdata/svg/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/svg/expected_symbols.txt index dd2e412302d..861198a8c92 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/svg/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/svg/expected_symbols.txt @@ -10,10 +10,8 @@ .cells.0.source.6 -.cells.0.outputs.0 +.cells.0.outputs .cells.0.outputs.0.data.image/svg+xml -.cells.0.outputs.1 - .cells.0.outputs.1.data.image/svg+xml diff --git a/vendor/gems/ipynbdiff/spec/testdata/text_output/expected.md b/vendor/gems/ipynbdiff/spec/testdata/text_output/expected.md index 924f4939f54..1b6c086ecd5 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/text_output/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/text_output/expected.md @@ -4,6 +4,6 @@ plt.plot(x, y) ``` -%%%% Output: execute_result +%% Output [<matplotlib.lines.Line2D at 0x12a4e43d0>] diff --git a/vendor/gems/ipynbdiff/spec/testdata/text_output/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/text_output/expected_symbols.txt index 179b30098a1..a004d852ba4 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/text_output/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/text_output/expected_symbols.txt @@ -4,6 +4,6 @@ .cells.0.source.0 -.cells.0.outputs.0 +.cells.0.outputs .cells.0.outputs.0.data.text/plain.0 diff --git a/vendor/gems/ipynbdiff/spec/testdata/text_png_output/expected.md b/vendor/gems/ipynbdiff/spec/testdata/text_png_output/expected.md index b1dda235951..c77f109378c 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/text_png_output/expected.md +++ b/vendor/gems/ipynbdiff/spec/testdata/text_png_output/expected.md @@ -7,10 +7,8 @@ y = 2 * np.sin(x) plt.plot(x, y) ``` -%%%% Output: execute_result +%% Output [<matplotlib.lines.Line2D at 0x12a4e43d0>] -%%%% Output: display_data - ![](data:image/png;base64,this_is_an_invalid_hash_for_testing_purposes) diff --git a/vendor/gems/ipynbdiff/spec/testdata/text_png_output/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/text_png_output/expected_symbols.txt index 5a86e4daa67..49f2d7149d8 100644 --- a/vendor/gems/ipynbdiff/spec/testdata/text_png_output/expected_symbols.txt +++ b/vendor/gems/ipynbdiff/spec/testdata/text_png_output/expected_symbols.txt @@ -7,10 +7,8 @@ .cells.0.source.3 -.cells.0.outputs.0 +.cells.0.outputs .cells.0.outputs.0.data.text/plain.0 -.cells.0.outputs.1 - .cells.0.outputs.1.data.image/png |