Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

features generate-docs: `$` sequences in NOTES.md and descriptions are expanded as String.replace patterns, splicing the README template into the output

未关闭 适合新手
#1,325 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
cli

调研方向

模板在 src/spec-node/collectionCommonUtils/generateDocsCommandImpl.ts 的第170–182行附近填充,其中以字符串值调用了 .replace()。将针对用户提供内容(notes、name、description、选项描述)的这些调用替换为 replacer 函数,然后重新运行复现:包含 $ 的 NOTES.md 应原样出现在生成的 README.md 中,且模板不会出现第二份副本。当输出与预期文本一致,并且 $'、$& 和 $$ 也保持不变时,即完成。

由索引模型根据 Issue 内容生成。

描述

Problem

If a Feature's NOTES.md contains $` (for example the markdown `$`), the generated README.md gets a second copy of the README template at that point: the title, the description, and an "Example Usage" block with literal #{Registry}/#{Namespace}/<id>:#{Version} and #{Customizations}. $', $& and $$ also misbehave, and so do name, description and option descriptions in devcontainer-feature.json.

Repro (CLI 0.89.0; same on main at 155f8b2)

mkdir -p src/demo
echo '{ "id": "demo", "version": "1.0.0", "name": "Demo", "description": "A demo." }' > src/demo/devcontainer-feature.json
echo 'Escape quotes, `$` or backslashes.' > src/demo/NOTES.md
devcontainer features generate-docs -p src -n x/y
  • Expected: Escape quotes, `$` or backslashes.
  • Actual: Escape quotes, `, then the template copy (# Demo (demo), ## Example Usage, #{Registry}/#{Namespace}/demo:#{Version}, #{Customizations}), then ` or backslashes.

Cause

src/spec-node/collectionCommonUtils/generateDocsCommandImpl.ts:170-182 fills the template with .replace('#{…}', value). With a string replacement, String.prototype.replace expands $`, $', $& and $$ (MDN). The same code is in devcontainers/action src/generateDocs.ts:152-162.

Suggested fix

Pass a replacer function, as in .replace('#{Notes}', () => generateNotesMarkdown()), for every placeholder that takes user content.

Not the same as #1324, which is about how option values are sourced at build time.

主要语言
TypeScript
星标
3k
派生
462
平均合并
13 小时 28 分钟
30 天内合并 PR
2

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

devcontainers/cli 的其他 Issue

查看 devcontainers/cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。