Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion news/changelog-1.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ All changes included in 1.8:

## Lua Filters

- ([#12727](https://github.com/quarto-dev/quarto-cli/issues/12727)): Do not crash in the presence of malformed tabset contents.
- ([#12727](https://github.com/quarto-dev/quarto-cli/issues/12727)): Do not crash in the presence of malformed tabset contents.

## Commands

### `inspect`

- ([#12733](https://github.com/quarto-dev/quarto-cli/issues/12733)): Add installed extensions to `quarto inspect` project report.
2 changes: 1 addition & 1 deletion src/command/inspect/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
setInitializer,
} from "../../core/lib/yaml-validation/state.ts";
import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts";
import { inspectConfig } from "../../quarto-core/inspect.ts";
import { inspectConfig } from "../../inspect/inspect.ts";

export const inspectCommand = new Command()
.name("inspect")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { Format } from "../config/types.ts";
import { Extension } from "../extension/types.ts";
import {
FileInclusion,
ProjectConfig,
Expand Down Expand Up @@ -38,6 +39,7 @@ export interface InspectedProjectConfig extends InspectedConfig {
dir: string;
config: ProjectConfig;
files: ProjectFiles;
extensions: Extension[];
}

export interface InspectedDocumentConfig extends InspectedConfig {
Expand Down
69 changes: 47 additions & 22 deletions src/quarto-core/inspect.ts → src/inspect/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
resolveFileResources,
resourcesFromMetadata,
} from "../command/render/resources.ts";
import { kLocalDevelopment, quartoConfig } from "../core/quarto.ts";
import { quartoConfig } from "../core/quarto.ts";

import { cssFileResourceReferences } from "../core/css.ts";
import {
Expand All @@ -31,7 +31,10 @@ import {
} from "../project/project-shared.ts";
import { normalizePath, safeExistsSync } from "../core/path.ts";
import { kExtensionDir } from "../extension/constants.ts";
import { extensionFilesFromDirs } from "../extension/extension.ts";
import {
createExtensionContext,
extensionFilesFromDirs,
} from "../extension/extension.ts";
import { withRenderServices } from "../command/render/render-services.ts";
import { notebookContext } from "../render/notebook/notebook-context.ts";
import { RenderServices } from "../command/render/types.ts";
Expand Down Expand Up @@ -88,27 +91,9 @@ const inspectProjectConfig = async (context: ProjectContext) => {
}
const fileInformation: Record<string, InspectedFile> = {};
for (const file of context.files.input) {
const engine = await fileExecutionEngine(file, undefined, context);
const src = await context.resolveFullMarkdownForFile(engine, file);
if (engine) {
const errors = await validateDocumentFromSource(
src,
engine.name,
error,
);
if (errors.length) {
throw new Error(`${file} is not a valid Quarto input document`);
}
}
await projectResolveCodeCellsForFile(context, engine, file);
await projectFileMetadata(context, file);
fileInformation[file] = {
includeMap: context.fileInformationCache.get(file)?.includeMap ??
[],
codeCells: context.fileInformationCache.get(file)?.codeCells ?? [],
metadata: context.fileInformationCache.get(file)?.metadata ?? {},
};
await populateFileInformation(context, fileInformation, file);
}
const extensions = await populateExtensionInformation(context);
const config: InspectedProjectConfig = {
quarto: {
version: quartoConfig.version(),
Expand All @@ -118,10 +103,50 @@ const inspectProjectConfig = async (context: ProjectContext) => {
config: context.config,
files: context.files,
fileInformation,
extensions: extensions,
};
return config;
};

const populateExtensionInformation = async (
context: ProjectContext,
) => {
const extensionContext = createExtensionContext();
return await extensionContext.extensions(
context.dir,
context.config,
context.dir,
{ builtIn: false },
);
};

const populateFileInformation = async (
context: ProjectContext,
fileInformation: Record<string, InspectedFile>,
file: string,
) => {
const engine = await fileExecutionEngine(file, undefined, context);
const src = await context.resolveFullMarkdownForFile(engine, file);
if (engine) {
const errors = await validateDocumentFromSource(
src,
engine.name,
error,
);
if (errors.length) {
throw new Error(`${file} is not a valid Quarto input document`);
}
}
await projectResolveCodeCellsForFile(context, engine, file);
await projectFileMetadata(context, file);
fileInformation[file] = {
includeMap: context.fileInformationCache.get(file)?.includeMap ??
[],
codeCells: context.fileInformationCache.get(file)?.codeCells ?? [],
metadata: context.fileInformationCache.get(file)?.metadata ?? {},
};
};

const inspectDocumentConfig = async (path: string) => {
const nbContext = notebookContext();
const project = await projectContext(path, nbContext) ||
Expand Down
2 changes: 1 addition & 1 deletion src/project/project-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { createTempContext } from "../core/temp.ts";
import { RenderContext, RenderFlags } from "../command/render/types.ts";
import { LanguageCellHandlerOptions } from "../core/handlers/types.ts";
import { ExecutionEngine } from "../execute/types.ts";
import { InspectedMdCell } from "../quarto-core/inspect-types.ts";
import { InspectedMdCell } from "../inspect/inspect-types.ts";
import { breakQuartoMd, QuartoMdCell } from "../core/lib/break-quarto-md.ts";
import { partitionCellOptionsText } from "../core/lib/partition-cell-options.ts";
import { parse } from "../core/yaml.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Brand, LightDarkBrand } from "../core/brand/brand.ts";
import { MappedString } from "../core/mapped-text.ts";
import { PartitionedMarkdown } from "../core/pandoc/types.ts";
import { ExecutionEngine, ExecutionTarget } from "../execute/types.ts";
import { InspectedMdCell } from "../quarto-core/inspect-types.ts";
import { InspectedMdCell } from "../inspect/inspect-types.ts";
import { NotebookContext } from "../render/notebook/notebook-types.ts";
import {
NavigationItem as NavItem,
Expand Down
2 changes: 1 addition & 1 deletion src/publish/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { projectOutputDir } from "../project/project-shared.ts";
import { PublishRecord } from "../publish/types.ts";
import { ProjectContext } from "../project/types.ts";
import { renderProgress } from "../command/render/render-info.ts";
import { inspectConfig, isDocumentConfig } from "../quarto-core/inspect.ts";
import { inspectConfig, isDocumentConfig } from "../inspect/inspect.ts";
import { kOutputFile, kTitle } from "../config/constants.ts";
import { inputFilesDir } from "../core/render.ts";
import {
Expand Down
2 changes: 2 additions & 0 deletions src/resources/schema/definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3026,3 +3026,5 @@
- string
- boolean
- number

# - id: quarto-extension
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# MODIFIED SOURCE -----------------------------------------------------------

Copyright (C) 2024 Garrick Aden-Buie
AGPL v3: https://www.gnu.org/licenses/agpl-3.0.en.html

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.


# ORIGINAL SOURCE -----------------------------------------------------------
# https://ar.al/2021/08/24/implementing-dark-mode-in-a-handful-of-lines-of-css-with-css-filters/

Copyright (C) 2021 Aral Balkan
AGPL v3: https://www.gnu.org/licenses/agpl-3.0.en.html

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: Auto Dark Mode
author: Garrick Aden-Buie
version: 1.0.0
quarto-required: ">=1.4.0"
contributes:
filters:
- auto-dark.lua

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Auto Dark Mode for Quarto
*
* https://github.com/gadenbuie/quarto-auto-dark
*
* License: Affero GPL v3, https://www.gnu.org/licenses/agpl-3.0.en.html
* Original: Aral Balkan
* https://ar.al/2021/08/24/implementing-dark-mode-in-a-handful-of-lines-of-css-with-css-filters/
*
* Modified: Garrick Aden-Buie
*
*/
@media (prefers-color-scheme: dark) {
/* Invert all elements on the body while attempting to not alter the hue substantially. */
body {
filter: invert(100%) hue-rotate(180deg);
}

/* Workarounds and optical adjustments. */

/*
Firefox workaround: Set the background colour for the html
element separately because, unlike other browsers, Firefox
doesn't apply the filter to the root element's background.
*/
html {
background-color: #111;
}

/* Do not invert media (revert the invert). */
img, video, iframe, svg:not(.bi, .fa) {
filter: invert(100%) hue-rotate(180deg);
}

/*
Videos running fullscreen are no longer affected by the
filter on the body so we need to also unset the
revert we applied earlier so we're left with no filter again.
*/
video:fullscreen {
filter: none;
}

/* Re-enable code block backgrounds. */
pre {
filter: invert(10%);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Pandoc()
if quarto.doc.is_format("html:js") then
quarto.doc.add_html_dependency({
name = "quarto-auto-dark-mode",
version = "1.0.0",
stylesheets = {"auto-dark-mode.css"}
})
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project:
type: website

website:
title: "extension-test"
navbar:
left:
- href: index.qmd
text: Home
- about.qmd

format:
html:
theme:
- cosmo
- brand
css: styles.css
toc: true



Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "About"
---

About this site
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "extension-test"
---

This is a Quarto website.

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* css styles */
41 changes: 41 additions & 0 deletions tests/smoke/inspect/inspect-extensions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* inspect-extensions.test.ts
*
* Copyright (C) 2025 Posit Software, PBC
*
*/
import { assertObjectMatch } from "https://deno.land/std@0.93.0/assert/assert_object_match.ts";
import { existsSync } from "../../../src/deno_ral/fs.ts";
import { FileInclusion } from "../../../src/project/types.ts";
import {
ExecuteOutput,
testQuartoCmd,
} from "../../test.ts";
import { assert, assertEquals } from "testing/asserts";

(() => {
const input = "docs/inspect/website-with-extensions/extension-test";
const output = "docs/inspect/website-with-extensions.json";
testQuartoCmd(
"inspect",
[input, output],
[
{
name: "inspect-extensions",
verify: async (outputs: ExecuteOutput[]) => {
assert(existsSync(output));
const json = JSON.parse(Deno.readTextFileSync(output));
assert(json.extensions.length === 1);
assertEquals(json.extensions[0].title, "Auto Dark Mode");
}
}
],
{
teardown: async () => {
if (existsSync(output)) {
Deno.removeSync(output);
}
}
},
);
})();
Loading