有没有人想出了一个很好的方法来生成类似于GuidedTour的文档。操场与html部分和swift代码的混合,而不必手动做?

我们可以探索playground文件的内容,该文件是一个包,它显示html/swift文件和内容。描述结构的xcplayground xml文件,但能够以用户友好的方式创建一个将是很好的。

有帮助吗?

解决方案 4

Vers 6.3此功能现在是Xcode的一部分。

引用从发布说明:

改进了文档创作,内联标记评论,内联游戏结果,能够查看和编辑嵌入游乐场中的资源,以及将辅助源文件集成到游乐场中的能力。这些功能使得在操场上创造丰富的新体验。

其他提示

虽然当前标记为“正确”的答案可能是在写作时才真实的,但实际上有几种方法可以这样做。

  • kildown:jason sandmeyer的swift-playground-builder在github上可以在 https://github.com/jas/Swift-Playground-Builder ,可以安装npm install -g swift-playground-builder。同样具有命令行,它也可以从JavaScript进行编程方式调用,因此来自GULP(需要Node.js和npm)
  • asciidoc:james carlson的ad2play在github上可在 https://github.com/jxxcarslson/ad2play并且可以作为Ruby Scriptip(需要Ruby和Asciidoctor安装)

在Sublime或IDE中打开playground文件夹。您需要编辑。其中的xcplayground扩展文件。playground文件夹,如您插入的地方 documentation 在swift之前或之后标记 code 标签。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='3.0' sdk='macosx'>
    <sections>
        <code source-file-name='section-1.swift' hidden="true" />
        <documentation relative-path='fragment0.html'/>
        <code source-file-name='section-3.swift'/>
        <documentation relative-path='fragment11.html'/>
        <code source-file-name='section-5.swift'/>
        <documentation relative-path='fragment21.html'/>
        <code source-file-name='section-7.swift'/>
        <documentation relative-path='fragment22.html'/>
        <code source-file-name='section-9.swift'/>
        <documentation relative-path='fragment23.html'/>
        <code source-file-name='section-11.swift'/>
        <documentation relative-path='fragment24.html'/>
        <code source-file-name='section-13.swift'/>
        <documentation relative-path='fragment25.html'/>
        <code source-file-name='section-15.swift'/>
        <documentation relative-path='fragment26.html'/>
        <code source-file-name='section-17.swift'/>
        <documentation relative-path='fragment27.html'/>
        <code source-file-name='section-19.swift'/>
        <documentation relative-path='fragment31.html'/>
        <code source-file-name='section-21.swift'/>
        <documentation relative-path='fragment32.html'/>
        <code source-file-name='section-23.swift'/>
        <documentation relative-path='fragment33.html'/>
    </sections>
    <timeline fileName='timeline.xctimeline'/>
</playground>

文档和Swift文件和文件夹结构需要这样。

Folder Structure

我很确定现在没有自动工作流程(至少没有公共场所)。但如果你真的需要它,为什么不创造自己的?

两种方式接缝对我来说是可行的,但问题当然是值得的。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top