-
Notifications
You must be signed in to change notification settings - Fork 28
Fix extra_files paths for subfolder Quarto documents
#762
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
Open
anders-wiggers
wants to merge
2
commits into
posit-dev:main
Choose a base branch
from
anders-wiggers:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13
−14
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1396,17 +1396,15 @@ def make_quarto_manifest( | |
| """ | ||
| if environment: | ||
| extra_files = list(extra_files or []) | ||
|
|
||
| base_dir = file_or_directory | ||
| if isdir(file_or_directory): | ||
| # Directory as a Quarto project. | ||
| excludes = list(excludes or []) + [".quarto"] | ||
|
|
||
| project_config = quarto_inspection.get("config", {}).get("project", {}) | ||
| output_dir = cast(Union[str, None], project_config.get("output-dir", None)) | ||
| if output_dir: | ||
| excludes = excludes + [output_dir] | ||
|
|
||
| files_data = quarto_inspection.get("files", {}) | ||
| files_input_data = files_data.get("input", []) | ||
| # files.input is a list of absolute paths to input (rendered) | ||
|
|
@@ -1419,19 +1417,23 @@ def make_quarto_manifest( | |
| for each in files_input_data: | ||
| t, _ = splitext(os.path.relpath(each, file_or_directory)) | ||
| excludes = excludes + [t + ".html", t + "_files/**/*"] | ||
|
|
||
| # relevant files don't need to include requirements.txt file because it is | ||
| # always added to the manifest (as a buffer) from the environment contents | ||
| if environment: | ||
| excludes.append(environment.filename) | ||
|
|
||
| relevant_files = _create_quarto_file_list(base_dir, extra_files, excludes) | ||
| else: | ||
| # Standalone Quarto document | ||
| base_dir = dirname(file_or_directory) | ||
| file_name = basename(file_or_directory) | ||
| relevant_files = [file_name] + list(extra_files or []) | ||
|
|
||
| # Use the common directory of the qmd and any extra files as base_dir. | ||
| # This avoids having the subfolder appear in both base_dir and rel_path. | ||
| all_files = [file_or_directory] + extra_files | ||
|
|
||
| abs_paths = [os.path.abspath(p) for p in all_files] | ||
| base_dir = os.path.commonpath(abs_paths) | ||
|
|
||
| # Store paths relative to base_dir | ||
| relevant_files = [os.path.relpath(p, base_dir) for p in abs_paths] | ||
|
|
||
| manifest = make_source_manifest( | ||
| app_mode, | ||
| environment, | ||
|
|
@@ -1441,13 +1443,10 @@ def make_quarto_manifest( | |
| env_management_py, | ||
| env_management_r, | ||
| ) | ||
|
|
||
| if environment: | ||
| manifest_add_buffer(manifest, environment.filename, environment.contents) | ||
|
|
||
| manifest_add_buffer(manifest, environment.filename, environment.contents) | ||
| for rel_path in relevant_files: | ||
| manifest_add_file(manifest, rel_path, base_dir) | ||
|
|
||
| manifest_add_file(manifest, rel_path, base_dir) | ||
|
Comment on lines
-1446
to
+1449
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are just whitespace changes, yeah? |
||
| return manifest, relevant_files | ||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I reading this correctly that this is using absolute paths at first then shifts them to relative paths (relative to the
base_dir)? Is there a way to avoid that back and forth and just go directly to paths relative to thebase_dir? It's not the end of the world if not, just seems like a bit of extra back and forth that is slightly distracting.