fix(destination): Allow the destination to reside in an arbitrary directory
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build is passing

That is to say, the destination will now be interpreted as an entire
  path relative to the source, not simply a filename in the same directory
  as the source.

  Resolves #20.
This commit is contained in:
Glen Whitney 2022-08-01 21:30:30 -07:00
parent 04a410a85b
commit f85c5fc6eb
25 changed files with 3724 additions and 5 deletions

View file

@ -401,9 +401,12 @@ semiliterate.ensurelines
if len(self.patterns) == 0:
self.patterns = [FlextractionPattern()]
# Note this needs to be identical to Semiliterate.try_extraction
# except with StreamInclusion in place of StreamExtract in the
# `extraction =` line, and a couple of options as noted below:
# Note that this has diverged noticeably from the
# Semiliterate.try_extraction method that it overrides, especially
# in regards to adjusting the destination directory.
# Hence, great care must be taken when mkdocs-simple-plugin is updated
# to make sure that any changes to this method are reflected in the
# code below:
def try_extraction(
self,
from_directory,
@ -418,6 +421,8 @@ semiliterate.ensurelines
if not to_file:
return False
from_file_path = os.path.join(from_directory, from_file)
to_file_path = os.path.join(destination_directory, to_file) # ## ADDED
(destination_directory, to_file) = os.path.split(to_file_path) # ADDED
try:
with open(from_file_path) as original_file:
utils.log.debug(f"mkdocs-semiliterate: Scanning {from_file}...")