【问题标题】:Include text from one apt to another apt包括从一个 apt 到另一个 apt 的文本
【发布时间】:2013-03-19 10:07:30
【问题描述】:

假设我有三个 apt 文件:

main.apt

Info, details, etc..

    some text

Configuration

    some text

child1.apt

Info, details, etc..

    some text

Configuration

    [Same text as MAIN.APT configuration]

child2.apt

Info, details, etc..

    some text

Configuration

    [Same text as MAIN.APT configuration]

我想遵循 DRY(不要重复自己)原则并重用 main.apt 中的文本并将其添加到 child1.apt 和 child2.apt。这对编写文档很有帮助。

我尝试过使用 sn-ps(首先生成带有 id 的站点文档,然后添加对这些 id 的引用):

~~START SNIPPET: id
~~END SNIPPET: id
%{snippet|id=id|url=http://svn.example.com/path/to/main.html}

并使用

生成网站
     mvn site:stage

,但这不起作用,因为它插入了未格式化为 html 的 html 文本块。我也试过 sn-ps 中的逐字参数,它没有帮助。

也许有人对此问题有解决方案和/或面临同样的问题?请告诉我你的故事,建议。解决方案可以节省我的时间:)

【问题讨论】:

    标签: java maven documentation-generation apt doxia


    【解决方案1】:

    使用Velocity。将 child1.apt 和 child2.apt 分别重命名为 child1.apt.vm 和 child2.apt.vm。然后替换

    [Same text as MAIN.APT configuration]
    

    #parse("main.apt")
    

    site.xml 中像其他任何页面一样包含子页面:

    <item name="child 1" href="child1.html"/>
    

    【讨论】:

      猜你喜欢
      • 2021-04-29
      • 1970-01-01
      • 2011-04-26
      • 2017-10-27
      • 2013-10-04
      • 2012-03-30
      • 1970-01-01
      • 1970-01-01
      • 2012-05-11
      相关资源
      最近更新 更多