【问题标题】:Is it possibile to write documentation for custom html components that gets displayed in the vscode popup when hovering the element?是否可以为悬停元素时在 vscode 弹出窗口中显示的自定义 html 组件编写文档?
【发布时间】:2017-10-25 09:23:28
【问题描述】:

就像 div 这样的标准 HTML 元素发生的情况一样,我想为我自己的自定义 Angular 组件编写文档,当将它们悬停在其他模板中时会显示这些组件 (my rer-card component for example)

我尝试添加

/** 
 * Test!!
 */

cmet 几乎在组件中的任何地方都没有发生。

有可能吗?

【问题讨论】:

    标签: html angular visual-studio-code


    【解决方案1】:

    v1.31 为自定义 html 和 css 添加了一些功能,请参阅custom html and css data support

    如今,前端开发人员经常使用 HTML/CSS 的超集进行编码:

    网络 组件允许自定义 HTML 元素,例如 .

    PostCSS 允许自定义 CSS 属性,例如 作为尺寸和尚未标准化的 CSS 功能,例如 :any-link。 各种框架在源代码中提供了更大的灵活性 HTML/CSS。

    在本次迭代中,我们改进了 HTML 自定义数据支持 在 1.30 中引入并添加了 CSS 自定义数据支持。采用 html.experimental.customDatacss.experimental.customData 加载 自定义数据。 (html.experimental.custom.tagshtml.experimental.custom.attributes 被删除。)或者, 将 JSON 捆绑到一个扩展中 contributes.html.experimental.customDatacontributes.css.experimental.customData

    最后,如果你正在写一个 使用 vscode-html-languageservice 的语言服务器或 vscode-css-languageservice,你可以创建语言服务 自定义数据。自定义数据增强了 VS Code 对 HTML/CSS 的理解。 例如,通过这些 HTML/CSS JSON 贡献,VS Code 可以 为自定义 HTML 标记/属性和 CSS 提供完成和悬停 属性/伪类:

    {
      "version": 1,
      "tags": [{
          "name": "my-button",
          "description": "My button",
          "attributes": [{
            "name": "type",
            "description": "My button type",
            "values": [
              { "name": "alert" }
            ]
          }]
      }]
    }
    

    {
      "version": 1,
      "properties": [{
        "name": "my-size",
        "description": "Compiles down to `width` and `height`. See details at https://github.com/postcss/postcss-size."
      }],
      "pseudoClasses": [{
        "name": ":my-link",
        "description": ":any-link pseudo class. See details at https://preset-env.cssdb.org/features#any-link-pseudo-class."
      }]
    }
    

    有关如何使用此功能的更多链接,请参阅此答案顶部的链接。

    【讨论】:

      猜你喜欢
      • 2016-12-17
      • 1970-01-01
      相关资源
      最近更新 更多