Skip to content

Commit

Permalink
Do not copy relative paths to directories
Browse files Browse the repository at this point in the history
Resolves #2617
  • Loading branch information
Gerrit0 committed Jun 26, 2024
1 parent 918d8aa commit 9f0fb04
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- `mailto:` links are no longer incorrectly recognized as relative paths, #2613.
- Added `@since` to the default list of recognized tags, #2614.
- Relative paths to directories will no longer cause the directory to be copied into the media directory, #2617.

## v0.26.2 (2024-06-24)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/comments/textParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function textContent(
data.pos = ref.end;
if (!ref.target) {
warning(
i18n.relative_path_0_does_not_exist(
i18n.relative_path_0_is_not_a_file_and_will_not_be_copied_to_output(
token.text.slice(ref.pos, ref.end),
),
{
Expand Down
5 changes: 2 additions & 3 deletions src/lib/internationalization/locales/jp.cts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export = buildIncompleteTranslation({
"TypeDoc は、コメント付きの単一の @template タグで定義された複数の型パラメータをサポートしていません。",
failed_to_find_jsdoc_tag_for_name_0:
"コメントを解析した後、{0} の JSDoc タグが見つかりませんでした。バグレポートを提出してください。",
relative_path_0_does_not_exist: "相対パス {0} は存在しません",
// relative_path_0_is_not_a_file_and_will_not_be_copied_to_output
inline_inheritdoc_should_not_appear_in_block_tag_in_comment_at_0:
"インライン @inheritDoc タグはブロック タグ内に出現しないでください。{0} のコメントでは処理されません。",
at_most_one_remarks_tag_expected_in_comment_at_0:
Expand Down Expand Up @@ -169,8 +169,7 @@ export = buildIncompleteTranslation({
file_0_not_an_object: "ファイル {0} はオブジェクトではありません",
serialized_project_referenced_0_not_part_of_project:
"シリアル化されたプロジェクトは、プロジェクトの一部ではないリフレクション {0} を参照しました",
saved_relative_path_0_resolved_from_1_does_not_exist:
"シリアル化されたプロジェクトは {0} を参照していますが、{1} に関連して存在しません",
// saved_relative_path_0_resolved_from_1_is_not_a_file
circular_reference_extends_0:
'{0} の "extends" フィールドで循環参照が検出されました',
failed_resolve_0_to_file_in_1:
Expand Down
5 changes: 2 additions & 3 deletions src/lib/internationalization/locales/zh.cts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export = buildIncompleteTranslation({
"TypeDoc 不支持在带有注释的单个 @template 标记中定义多个类型参数",
failed_to_find_jsdoc_tag_for_name_0:
"解析注释后无法找到 {0} 的 JSDoc 标签,请提交错误报告",
relative_path_0_does_not_exist: "相对路径 {0} 不存在",
// relative_path_0_is_not_a_file_and_will_not_be_copied_to_output
inline_inheritdoc_should_not_appear_in_block_tag_in_comment_at_0:
"内联 @inheritDoc 标记不应出现在块标记内,因为它不会在 {0} 处的注释中被处理。",
at_most_one_remarks_tag_expected_in_comment_at_0:
Expand Down Expand Up @@ -145,8 +145,7 @@ export = buildIncompleteTranslation({
file_0_not_an_object: "文件 {0} 不是对象",
serialized_project_referenced_0_not_part_of_project:
"序列化项目引用了反射 {0},但它不是项目的一部分",
saved_relative_path_0_resolved_from_1_does_not_exist:
"序列化项目引用了 {0},相对于 {1} 而言,它并不存在",
// saved_relative_path_0_resolved_from_1_is_not_a_file
circular_reference_extends_0: "{0} 的“extends”字段出现循环引用",
failed_resolve_0_to_file_in_1: "无法将 {0} 解析为 {1} 中的文件",
option_0_can_only_be_specified_by_config_file:
Expand Down
16 changes: 8 additions & 8 deletions src/lib/internationalization/translatable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type {
modifierTags,
} from "../utils/options/tsdoc-defaults";

export function buildTranslation<
T extends BuiltinTranslatableStringConstraints,
>(translations: T) {
export function buildTranslation(
translations: BuiltinTranslatableStringConstraints,
) {
return translations;
}

export function buildIncompleteTranslation<
T extends Partial<BuiltinTranslatableStringConstraints>,
>(translations: T) {
export function buildIncompleteTranslation(
translations: Partial<BuiltinTranslatableStringConstraints>,
) {
return translations;
}

Expand Down Expand Up @@ -72,7 +72,7 @@ export const translatable = {
// comments/parser.ts
multiple_type_parameters_on_template_tag_unsupported: `TypeDoc does not support multiple type parameters defined in a single @template tag with a comment`,
failed_to_find_jsdoc_tag_for_name_0: `Failed to find JSDoc tag for {0} after parsing comment, please file a bug report`,
relative_path_0_does_not_exist: `The relative path {0} does not exist`,
relative_path_0_is_not_a_file_and_will_not_be_copied_to_output: `The relative path {0} is not a file and will not be copied to the output directory`,

inline_inheritdoc_should_not_appear_in_block_tag_in_comment_at_0:
"An inline @inheritDoc tag should not appear within a block tag as it will not be processed in comment at {0}",
Expand Down Expand Up @@ -159,7 +159,7 @@ export const translatable = {

// deserialization
serialized_project_referenced_0_not_part_of_project: `Serialized project referenced reflection {0}, which was not a part of the project`,
saved_relative_path_0_resolved_from_1_does_not_exist: `Serialized project referenced {0}, which does not exist relative to {1}`,
saved_relative_path_0_resolved_from_1_is_not_a_file: `Serialized project referenced {0}, which does not exist or is not a file relative to {1}`,

// options
circular_reference_extends_0: `Circular reference encountered for "extends" field of {0}`,
Expand Down
9 changes: 4 additions & 5 deletions src/lib/models/FileRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { basename, dirname, parse, relative, resolve } from "path";
import type { Deserializer, Serializer } from "../serialization";
import type { FileRegistry as JSONFileRegistry } from "../serialization/schema";
import { normalizePath } from "../utils";
import { existsSync } from "fs";
import { isFile, normalizePath } from "../utils";
import type { Reflection } from "./reflections";

export class FileRegistry {
Expand Down Expand Up @@ -137,7 +136,7 @@ export class ValidatingFileRegistry extends FileRegistry {
relativePath: string,
): number | undefined {
const absolute = resolve(dirname(sourcePath), relativePath);
if (!existsSync(absolute)) {
if (!isFile(absolute)) {
return;
}
return this.registerAbsolute(absolute);
Expand All @@ -146,9 +145,9 @@ export class ValidatingFileRegistry extends FileRegistry {
override fromObject(de: Deserializer, obj: JSONFileRegistry) {
for (const [key, val] of Object.entries(obj.entries)) {
const absolute = normalizePath(resolve(de.projectRoot, val));
if (!existsSync(absolute)) {
if (!isFile(absolute)) {
de.logger.warn(
de.logger.i18n.saved_relative_path_0_resolved_from_1_does_not_exist(
de.logger.i18n.saved_relative_path_0_resolved_from_1_is_not_a_file(
val,
de.projectRoot,
),
Expand Down

0 comments on commit 9f0fb04

Please sign in to comment.