ドキュメンテーションの遊び場を作成する方法(HTMLとSwiftコードをミキフト化)?

StackOverflow https://stackoverflow.com//questions/24054852

  •  22-12-2019
  •  | 
  •  

質問

誰もがGuouseTour.playgroundに似た文書を作成するための良い方法を考え出して、手動でそれをする必要なしにHTMLセクションとSwiftコードを混在させますか?

パッケージである遊具ファイルの内容を探索し、その構造を説明するHTML / SWIFTファイルとContents.xcplayground XMLファイルを表示しますが、ユーザーフレンドリーな方法で1つを作成できるのはうれしいです。。

役に立ちましたか?

解決 4

バージョン6.3以降この機能はXcodeの一部です。

リリースからの引用注:

インラインマークアップコメント、インライン遊び場の結果、遊び場に埋め込まれたリソースを表示および編集する機能、および補助ソースファイルを遊び場に統合する機能。これらの機能により、遊び場で豊富な新しい経験を作成できます。

他のヒント

現在「正しい」とマークされている答えは、書く時点で真実だったかもしれませんが、実際にはこれを行う方法がいくつかあります。

  • マークダウン:Jason Sandmeyerのswift-playground-builderは、GitHubでGithubで入手可能です。Swift-Playground-Builder とnpm install -g swift-playground-builderでインストールできます。コマンドラインを持つことも、JavaScriptからプログラム的に呼び出され、したがってGULPからも呼び出されます(node.jsとnpmが必要です)
  • ASCIIDOC:James Carlsonのad2playは、 https://github.com/jxxcarlson/ad2play そしてルビースクリプトとして実行することができます(RubyおよびAsciidoctorがインストールされている)

昇華またはIDEの遊び場フォルダを開きます。Swift documentationタグの直前または直後のcodeタグを挿入するように、その.playgroundフォルダ内の.playgroundフォルダ内の.playgroundフォルダを編集する必要があります。

<?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ファイルとフォルダ構造はこのようなものである必要があります。

フォルダ構造

私は今のところ自動化されたワークフロー(少なくとも公開1)がないと確信しています。しかし、あなたが本当にそれを必要とするならあなた自身を作成しないのはなぜですか?

両方の方法は私に実現可能であるが、それがそれが価値があるならば、問題はもちろんのものです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top