From c1a529ea78a94cb4272d8cef7fc235babf7969e8 Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 2 Sep 2021 01:46:45 +0100 Subject: [PATCH 01/10] changed readme links to relative --- README.rst | 240 +++++++++++++++++++++++++-------------------------- docs/conf.py | 5 ++ 2 files changed, 125 insertions(+), 120 deletions(-) diff --git a/README.rst b/README.rst index 7331ca66..7fb5fd35 100644 --- a/README.rst +++ b/README.rst @@ -10,125 +10,125 @@ for a variety of problems with the functions it provides. In ``more-itertools`` we collect additional building blocks, recipes, and routines for working with Python iterables. -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Grouping | `chunked `_, | -| | `ichunked `_, | -| | `sliced `_, | -| | `distribute `_, | -| | `divide `_, | -| | `split_at `_, | -| | `split_before `_, | -| | `split_after `_, | -| | `split_into `_, | -| | `split_when `_, | -| | `bucket `_, | -| | `unzip `_, | -| | `grouper `_, | -| | `partition `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Lookahead and lookback | `spy `_, | -| | `peekable `_, | -| | `seekable `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Windowing | `windowed `_, | -| | `substrings `_, | -| | `substrings_indexes `_, | -| | `stagger `_, | -| | `windowed_complete `_, | -| | `pairwise `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Augmenting | `count_cycle `_, | -| | `intersperse `_, | -| | `padded `_, | -| | `mark_ends `_, | -| | `repeat_last `_, | -| | `adjacent `_, | -| | `groupby_transform `_, | -| | `padnone `_, | -| | `ncycles `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Combining | `collapse `_, | -| | `sort_together `_, | -| | `interleave `_, | -| | `interleave_longest `_, | -| | `interleave_evenly `_, | -| | `zip_offset `_, | -| | `zip_equal `_, | -| | `dotproduct `_, | -| | `convolve `_, | -| | `flatten `_, | -| | `roundrobin `_, | -| | `prepend `_, | -| | `value_chain `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Summarizing | `ilen `_, | -| | `unique_to_each `_, | -| | `sample `_, | -| | `consecutive_groups `_, | -| | `run_length `_, | -| | `map_reduce `_, | -| | `exactly_n `_, | -| | `is_sorted `_, | -| | `all_equal `_, | -| | `all_unique `_, | -| | `first_true `_, | -| | `quantify `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Selecting | `islice_extended `_, | -| | `first `_, | -| | `last `_, | -| | `one `_, | -| | `only `_, | -| | `strip `_, | -| | `lstrip `_, | -| | `rstrip `_, | -| | `filter_except `_ | -| | `map_except `_ | -| | `nth_or_last `_, | -| | `nth `_, | -| | `take `_, | -| | `tail `_, | -| | `unique_everseen `_, | -| | `unique_justseen `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Combinatorics | `distinct_permutations `_, | -| | `distinct_combinations `_, | -| | `circular_shifts `_, | -| | `partitions `_, | -| | `set_partitions `_, | -| | `product_index `_, | -| | `combination_index `_, | -| | `permutation_index `_, | -| | `powerset `_, | -| | `random_product `_, | -| | `random_permutation `_, | -| | `random_combination `_, | -| | `random_combination_with_replacement `_, | -| | `nth_product `_ | -| | `nth_permutation `_ | -| | `nth_combination `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Wrapping | `always_iterable `_, | -| | `always_reversible `_, | -| | `countable `_, | -| | `consumer `_, | -| | `with_iter `_, | -| | `iter_except `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Others | `locate `_, | -| | `rlocate `_, | -| | `replace `_, | -| | `numeric_range `_, | -| | `side_effect `_, | -| | `iterate `_, | -| | `difference `_, | -| | `make_decorator `_, | -| | `SequenceView `_, | -| | `time_limited `_, | -| | `consume `_, | -| | `tabulate `_, | -| | `repeatfunc `_ | -+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Grouping | `chunked `_, | +| | `ichunked `_, | +| | `sliced `_, | +| | `distribute `_, | +| | `divide `_, | +| | `split_at `_, | +| | `split_before `_, | +| | `split_after `_, | +| | `split_into `_, | +| | `split_when `_, | +| | `bucket `_, | +| | `unzip `_, | +| | `grouper `_, | +| | `partition `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Lookahead and lookback | `spy `_, | +| | `peekable `_, | +| | `seekable `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Windowing | `windowed `_, | +| | `substrings `_, | +| | `substrings_indexes `_, | +| | `stagger `_, | +| | `windowed_complete `_, | +| | `pairwise `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Augmenting | `count_cycle `_, | +| | `intersperse `_, | +| | `padded `_, | +| | `mark_ends `_, | +| | `repeat_last `_, | +| | `adjacent `_, | +| | `groupby_transform `_, | +| | `padnone `_, | +| | `ncycles `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Combining | `collapse `_, | +| | `sort_together `_, | +| | `interleave `_, | +| | `interleave_longest `_, | +| | `interleave_evenly `_, | +| | `zip_offset `_, | +| | `zip_equal `_, | +| | `dotproduct `_, | +| | `convolve `_, | +| | `flatten `_, | +| | `roundrobin `_, | +| | `prepend `_, | +| | `value_chain `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Summarizing | `ilen `_, | +| | `unique_to_each `_, | +| | `sample `_, | +| | `consecutive_groups `_, | +| | `run_length `_, | +| | `map_reduce `_, | +| | `exactly_n `_, | +| | `is_sorted `_, | +| | `all_equal `_, | +| | `all_unique `_, | +| | `first_true `_, | +| | `quantify `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Selecting | `islice_extended `_, | +| | `first `_, | +| | `last `_, | +| | `one `_, | +| | `only `_, | +| | `strip `_, | +| | `lstrip `_, | +| | `rstrip `_, | +| | `filter_except `_ | +| | `map_except `_ | +| | `nth_or_last `_, | +| | `nth `_, | +| | `take `_, | +| | `tail `_, | +| | `unique_everseen `_, | +| | `unique_justseen `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Combinatorics | `distinct_permutations `_, | +| | `distinct_combinations `_, | +| | `circular_shifts `_, | +| | `partitions `_, | +| | `set_partitions `_, | +| | `product_index `_, | +| | `combination_index `_, | +| | `permutation_index `_, | +| | `powerset `_, | +| | `random_product `_, | +| | `random_permutation `_, | +| | `random_combination `_, | +| | `random_combination_with_replacement `_, | +| | `nth_product `_ | +| | `nth_permutation `_ | +| | `nth_combination `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Wrapping | `always_iterable `_, | +| | `always_reversible `_, | +| | `countable `_, | +| | `consumer `_, | +| | `with_iter `_, | +| | `iter_except `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ +| Others | `locate `_, | +| | `rlocate `_, | +| | `replace `_, | +| | `numeric_range `_, | +| | `side_effect `_, | +| | `iterate `_, | +| | `difference `_, | +| | `make_decorator `_, | +| | `SequenceView `_, | +| | `time_limited `_, | +| | `consume `_, | +| | `tabulate `_, | +| | `repeatfunc `_ | ++------------------------+-------------------------------------------------------------------------------------------------------+ Getting started @@ -169,7 +169,7 @@ Several new recipes are available as well: -For the full listing of functions, see the `API documentation `_. +For the full listing of functions, see the `API documentation `_. Links elsewhere diff --git a/docs/conf.py b/docs/conf.py index 3d404d61..9cac2d2f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -262,3 +262,8 @@ # How to display URL addresses: 'footnote', 'no', or 'inline'. # texinfo_show_urls = 'footnote' + +# -- Options for Linkcheck ------------------------------------------------ + +# Links to ignore during linkcheck, specified as regex patterns +linkcheck_ignore = [r'^api\.html(#more_itertools\.\w+)?'] From 9dc24afcec4e10dbc85a964bddb5cc2a996f0654 Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 2 Sep 2021 01:57:53 +0100 Subject: [PATCH 02/10] two more commas --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 7fb5fd35..fe1bf764 100644 --- a/README.rst +++ b/README.rst @@ -104,8 +104,8 @@ Python iterables. | | `random_permutation `_, | | | `random_combination `_, | | | `random_combination_with_replacement `_, | -| | `nth_product `_ | -| | `nth_permutation `_ | +| | `nth_product `_, | +| | `nth_permutation `_, | | | `nth_combination `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ | Wrapping | `always_iterable `_, | From 0f794eeec291cf4323d0a42a38f230fd20b02360 Mon Sep 17 00:00:00 2001 From: Marcin Date: Fri, 3 Sep 2021 13:19:42 +0100 Subject: [PATCH 03/10] added readme preprocessor to conf.py --- README.rst | 218 ++++++++++++++++++++++++------------------------- docs/conf.py | 16 ++++ docs/index.rst | 2 +- 3 files changed, 126 insertions(+), 110 deletions(-) diff --git a/README.rst b/README.rst index fe1bf764..d34a5386 100644 --- a/README.rst +++ b/README.rst @@ -11,123 +11,123 @@ we collect additional building blocks, recipes, and routines for working with Python iterables. +------------------------+-------------------------------------------------------------------------------------------------------+ -| Grouping | `chunked `_, | -| | `ichunked `_, | -| | `sliced `_, | -| | `distribute `_, | -| | `divide `_, | -| | `split_at `_, | -| | `split_before `_, | -| | `split_after `_, | -| | `split_into `_, | -| | `split_when `_, | -| | `bucket `_, | -| | `unzip `_, | -| | `grouper `_, | -| | `partition `_ | +| Grouping | `chunked `_, | +| | `ichunked `_, | +| | `sliced `_, | +| | `distribute `_, | +| | `divide `_, | +| | `split_at `_, | +| | `split_before `_, | +| | `split_after `_, | +| | `split_into `_, | +| | `split_when `_, | +| | `bucket `_, | +| | `unzip `_, | +| | `grouper `_, | +| | `partition `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Lookahead and lookback | `spy `_, | -| | `peekable `_, | -| | `seekable `_ | +| Lookahead and lookback | `spy `_, | +| | `peekable `_, | +| | `seekable `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Windowing | `windowed `_, | -| | `substrings `_, | -| | `substrings_indexes `_, | -| | `stagger `_, | -| | `windowed_complete `_, | -| | `pairwise `_ | +| Windowing | `windowed `_, | +| | `substrings `_, | +| | `substrings_indexes `_, | +| | `stagger `_, | +| | `windowed_complete `_, | +| | `pairwise `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Augmenting | `count_cycle `_, | -| | `intersperse `_, | -| | `padded `_, | -| | `mark_ends `_, | -| | `repeat_last `_, | -| | `adjacent `_, | -| | `groupby_transform `_, | -| | `padnone `_, | -| | `ncycles `_ | +| Augmenting | `count_cycle `_, | +| | `intersperse `_, | +| | `padded `_, | +| | `mark_ends `_, | +| | `repeat_last `_, | +| | `adjacent `_, | +| | `groupby_transform `_, | +| | `padnone `_, | +| | `ncycles `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Combining | `collapse `_, | -| | `sort_together `_, | -| | `interleave `_, | -| | `interleave_longest `_, | -| | `interleave_evenly `_, | -| | `zip_offset `_, | -| | `zip_equal `_, | -| | `dotproduct `_, | -| | `convolve `_, | -| | `flatten `_, | -| | `roundrobin `_, | -| | `prepend `_, | -| | `value_chain `_ | +| Combining | `collapse `_, | +| | `sort_together `_, | +| | `interleave `_, | +| | `interleave_longest `_, | +| | `interleave_evenly `_, | +| | `zip_offset `_, | +| | `zip_equal `_, | +| | `dotproduct `_, | +| | `convolve `_, | +| | `flatten `_, | +| | `roundrobin `_, | +| | `prepend `_, | +| | `value_chain `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Summarizing | `ilen `_, | -| | `unique_to_each `_, | -| | `sample `_, | -| | `consecutive_groups `_, | -| | `run_length `_, | -| | `map_reduce `_, | -| | `exactly_n `_, | -| | `is_sorted `_, | -| | `all_equal `_, | -| | `all_unique `_, | -| | `first_true `_, | -| | `quantify `_ | +| Summarizing | `ilen `_, | +| | `unique_to_each `_, | +| | `sample `_, | +| | `consecutive_groups `_, | +| | `run_length `_, | +| | `map_reduce `_, | +| | `exactly_n `_, | +| | `is_sorted `_, | +| | `all_equal `_, | +| | `all_unique `_, | +| | `first_true `_, | +| | `quantify `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Selecting | `islice_extended `_, | -| | `first `_, | -| | `last `_, | -| | `one `_, | -| | `only `_, | -| | `strip `_, | -| | `lstrip `_, | -| | `rstrip `_, | -| | `filter_except `_ | -| | `map_except `_ | -| | `nth_or_last `_, | -| | `nth `_, | -| | `take `_, | -| | `tail `_, | -| | `unique_everseen `_, | -| | `unique_justseen `_ | +| Selecting | `islice_extended `_, | +| | `first `_, | +| | `last `_, | +| | `one `_, | +| | `only `_, | +| | `strip `_, | +| | `lstrip `_, | +| | `rstrip `_, | +| | `filter_except `_ | +| | `map_except `_ | +| | `nth_or_last `_, | +| | `nth `_, | +| | `take `_, | +| | `tail `_, | +| | `unique_everseen `_, | +| | `unique_justseen `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Combinatorics | `distinct_permutations `_, | -| | `distinct_combinations `_, | -| | `circular_shifts `_, | -| | `partitions `_, | -| | `set_partitions `_, | -| | `product_index `_, | -| | `combination_index `_, | -| | `permutation_index `_, | -| | `powerset `_, | -| | `random_product `_, | -| | `random_permutation `_, | -| | `random_combination `_, | -| | `random_combination_with_replacement `_, | -| | `nth_product `_, | -| | `nth_permutation `_, | -| | `nth_combination `_ | +| Combinatorics | `distinct_permutations `_, | +| | `distinct_combinations `_, | +| | `circular_shifts `_, | +| | `partitions `_, | +| | `set_partitions `_, | +| | `product_index `_, | +| | `combination_index `_, | +| | `permutation_index `_, | +| | `powerset `_, | +| | `random_product `_, | +| | `random_permutation `_, | +| | `random_combination `_, | +| | `random_combination_with_replacement `_, | +| | `nth_product `_, | +| | `nth_permutation `_, | +| | `nth_combination `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Wrapping | `always_iterable `_, | -| | `always_reversible `_, | -| | `countable `_, | -| | `consumer `_, | -| | `with_iter `_, | -| | `iter_except `_ | +| Wrapping | `always_iterable `_, | +| | `always_reversible `_, | +| | `countable `_, | +| | `consumer `_, | +| | `with_iter `_, | +| | `iter_except `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ -| Others | `locate `_, | -| | `rlocate `_, | -| | `replace `_, | -| | `numeric_range `_, | -| | `side_effect `_, | -| | `iterate `_, | -| | `difference `_, | -| | `make_decorator `_, | -| | `SequenceView `_, | -| | `time_limited `_, | -| | `consume `_, | -| | `tabulate `_, | -| | `repeatfunc `_ | +| Others | `locate `_, | +| | `rlocate `_, | +| | `replace `_, | +| | `numeric_range `_, | +| | `side_effect `_, | +| | `iterate `_, | +| | `difference `_, | +| | `make_decorator `_, | +| | `SequenceView `_, | +| | `time_limited `_, | +| | `consume `_, | +| | `tabulate `_, | +| | `repeatfunc `_ | +------------------------+-------------------------------------------------------------------------------------------------------+ @@ -169,7 +169,7 @@ Several new recipes are available as well: -For the full listing of functions, see the `API documentation `_. +For the full listing of functions, see the `API documentation `_. Links elsewhere diff --git a/docs/conf.py b/docs/conf.py index 9cac2d2f..a1ecd82a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,6 +21,22 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('..')) +# -- Preprocess README.rst ----------------------------------------------------- + +with open('../README.rst', 'r+') as source: + readme_file = source.readlines() + +# Change absolute links in README.rst to relative ones. This way the online +# documentation copmiles with relative links, while README.rst on GitHub can +# have absolute links. See issue #551. +root_path = 'https://more-itertools.readthedocs.io/en/stable/' +with open('./_build/README.pprst', 'w') as target: + for line in readme_file: + # skip lines where the absolute link is specified as an explicit target + if ':target: ' + root_path not in line: + line = line.replace(root_path, '') + target.write(line) + # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. diff --git a/docs/index.rst b/docs/index.rst index 091461ff..23e4ac27 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,4 +1,4 @@ -.. include:: ../README.rst +.. include:: ./_build/README.pprst Contents ======== From 37ad6f438425adb772f65780b6be312239afc4e1 Mon Sep 17 00:00:00 2001 From: Marcin Date: Fri, 3 Sep 2021 13:22:06 +0100 Subject: [PATCH 04/10] updated import position --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a1ecd82a..a6636762 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,13 +14,13 @@ import sphinx_rtd_theme -import more_itertools - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('..')) +import more_itertools + # -- Preprocess README.rst ----------------------------------------------------- with open('../README.rst', 'r+') as source: From 35a25d80b29e67b2fa91fbe64e584692300daa88 Mon Sep 17 00:00:00 2001 From: Marcin Date: Fri, 3 Sep 2021 14:16:26 +0100 Subject: [PATCH 05/10] fixed rst table preprocessing --- docs/conf.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a6636762..8d3394f9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,6 +23,8 @@ # -- Preprocess README.rst ----------------------------------------------------- +import re + with open('../README.rst', 'r+') as source: readme_file = source.readlines() @@ -30,11 +32,21 @@ # documentation copmiles with relative links, while README.rst on GitHub can # have absolute links. See issue #551. root_path = 'https://more-itertools.readthedocs.io/en/stable/' +in_table = False with open('./_build/README.pprst', 'w') as target: - for line in readme_file: - # skip lines where the absolute link is specified as an explicit target + for line, next_line in more_itertools.pairwise(readme_file + ['']): + + # Check whether we're in the middle of a rst table + if re.match('\+-+\+-+', line): + in_table = bool(re.match('\|[^\|]+\|[^\|]+\|', next_line)) + + # Skip lines where the absolute link is specified as an explicit target if ':target: ' + root_path not in line: - line = line.replace(root_path, '') + if root_path in line: + line = line.replace(root_path, '') + if in_table: + line = line[:-2] + ' ' * len(root_path) + line[-2:] + target.write(line) # -- General configuration ----------------------------------------------------- From 45cff098ac5a266b06cc2f16220697ca5eede6bc Mon Sep 17 00:00:00 2001 From: Marcin Date: Fri, 3 Sep 2021 14:22:18 +0100 Subject: [PATCH 06/10] added os.path.abspath for git build --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 8d3394f9..02e3a678 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ import re -with open('../README.rst', 'r+') as source: +with open(os.path.abspath('../README.rst'), 'r+') as source: readme_file = source.readlines() # Change absolute links in README.rst to relative ones. This way the online @@ -33,7 +33,7 @@ # have absolute links. See issue #551. root_path = 'https://more-itertools.readthedocs.io/en/stable/' in_table = False -with open('./_build/README.pprst', 'w') as target: +with open(os.path.abspath('./_build/README.pprst'), 'w') as target: for line, next_line in more_itertools.pairwise(readme_file + ['']): # Check whether we're in the middle of a rst table From 0e9a95778a04d7695dbabd09534a7a96e3941024 Mon Sep 17 00:00:00 2001 From: Marcin Date: Fri, 3 Sep 2021 14:29:33 +0100 Subject: [PATCH 07/10] added w+ for git workflow --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 02e3a678..a74bbd5c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,7 +33,7 @@ # have absolute links. See issue #551. root_path = 'https://more-itertools.readthedocs.io/en/stable/' in_table = False -with open(os.path.abspath('./_build/README.pprst'), 'w') as target: +with open(os.path.abspath('./_build/README.pprst'), 'w+') as target: for line, next_line in more_itertools.pairwise(readme_file + ['']): # Check whether we're in the middle of a rst table From 20b43f0801dc64356fe8f34e4c7bbd6a27edc9b6 Mon Sep 17 00:00:00 2001 From: Marcin Date: Fri, 3 Sep 2021 14:50:07 +0100 Subject: [PATCH 08/10] create _build dir in readme preprocessor --- docs/conf.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a74bbd5c..320793bb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,15 +25,20 @@ import re -with open(os.path.abspath('../README.rst'), 'r+') as source: +with open('../README.rst', 'r+') as source: readme_file = source.readlines() +# Make sure build directory exists. This is required for github workflow. +build_dir = '_build' +if not os.path.exists(build_dir): + os.makedirs(build_dir) + # Change absolute links in README.rst to relative ones. This way the online # documentation copmiles with relative links, while README.rst on GitHub can # have absolute links. See issue #551. root_path = 'https://more-itertools.readthedocs.io/en/stable/' in_table = False -with open(os.path.abspath('./_build/README.pprst'), 'w+') as target: +with open(os.path.join('.', build_dir, 'README.pprst'), 'w+') as target: for line, next_line in more_itertools.pairwise(readme_file + ['']): # Check whether we're in the middle of a rst table @@ -95,7 +100,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = [build_dir] # The reST default role (used for this markup: `text`) to use for all documents. # default_role = None From 32b46e2f0310f3e1a2646e07b7318bfd2085c38f Mon Sep 17 00:00:00 2001 From: Marcin Date: Sun, 5 Sep 2021 20:41:18 +0100 Subject: [PATCH 09/10] use os.makedir --- docs/conf.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 320793bb..676206fe 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,15 +30,14 @@ # Make sure build directory exists. This is required for github workflow. build_dir = '_build' -if not os.path.exists(build_dir): - os.makedirs(build_dir) +os.makedirs(build_dir, exist_ok=True) # Change absolute links in README.rst to relative ones. This way the online # documentation copmiles with relative links, while README.rst on GitHub can # have absolute links. See issue #551. root_path = 'https://more-itertools.readthedocs.io/en/stable/' in_table = False -with open(os.path.join('.', build_dir, 'README.pprst'), 'w+') as target: +with open(os.path.join('.', build_dir, 'README.pprst'), 'w') as target: for line, next_line in more_itertools.pairwise(readme_file + ['']): # Check whether we're in the middle of a rst table From 248783cf74119e8c183d7df87ccfcabdd78c0499 Mon Sep 17 00:00:00 2001 From: Marcin Date: Sun, 5 Sep 2021 20:47:18 +0100 Subject: [PATCH 10/10] trigger build