Interactive Learning Document Format Reference

Interactive Learning Document Format Reference

An interactive learning document is a kind of playground that lets the reader interact with code mixed with rich HTML content. Its file format is a package that contains Swift source code, HTML content, assets such as CSS and images, and a manifest file.

For example, the directory structure of an example document is as follows:

  • My Example.playground

    • contents.xcplayground
    • Documentation/
      • style.css
      • Art/
        • cow.png
        • dog.jpg
      • section–1.html
      • section-3.html
    • Resources/
      • data.json
      • background.png
    • section–2.swift
    • section–4.swift

The manifest is an XML file named contents.xcplayground at the top level of the package. Example contents.xcplayground file shows the manifest file for an example playground.

Listing 2-1  Example contents.xcplayground file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version=‘3.0‘ sdk=‘macosx‘ allows-reset=‘YES‘>
    <sections>
        <code source-file-name=‘section-1.swift‘/>
        <documentation relative-path=‘section-2.html‘/>
        <code source-file-name=‘section-3.swift‘/>
        <documentation relative-path=‘section-4.html‘/>
    </sections>
    <timeline fileName=‘timeline.xctimeline‘/>
</playground>

The manifest contains the XML elements described below.

playground

Root element of the XML file.

Contains one sections element and one timeline element.

Attributes

version

Required. File format version. Use 3.0 as the value.

Important: Always check the version number. The interactive learning document file format is expected to continue to evolve. Future versions of this file format might have different elements, attributes, or structure.

sdk

Required. SDK used by the playground. Use macosx for OS X or iphonesimulator for iOS—Xcode always uses most recent version of the selected SDK.

allows-reset

Indicates whether users can edit the playground and then reset it to its original state. Use yes to enable resetting or no (the default).

If resetting is enabled, when the user edits a playground, Xcode saves a copy of the original source code files at the top level of the package, adding the suffix -original to their filenames. These original files do not appear in the manifest and shouldn’t be edited.

sections

List of the sections of the document.

Contains documentation and code elements.

documentation

HTML documentation section.

Each HTMS documentation section is rendered in its own web view. This means, for example, that JavaScript running in one section can access the DOM structure of only that some section.

Attributes

relative-path

Required. Path to the HTML file relative to the Documentation folder at the top level of the package.

All HTML files and resources such as images and CSS files that are used by the those files are stored in the Documentation folder. You can organize the Documentation folder with subfolders.

code

Swift source code section.

The file names of code sections are not guaranteed to be preserved after the user edits the document in Xcode.

Attributes

source-file-name

Required. File name of the Swift source file.

All Swift source files are stored at the top level of the package.

Assets such as images and input data that are used by the Swift code are stored in the Resources folder at the top level of the package.

style

Display style for the code fragment.

To display the code in a disclosable region, use setup as the value.

timeline

Xcode timeline information. This element and the file it refers to are populated by Xcode based on the items in the playground’s timeline, and shouldn’t be edited by hand.

时间: 2024-10-10 01:46:49

Interactive Learning Document Format Reference的相关文章

A printf format reference page (cheat sheet)

Summary: This page is a printf formatting cheat sheet. I originally created this cheat sheet for my own purposes, and then thought I would share it here. A cool thing about the printf formatting syntax is that the specifiers you can use are very simi

Machine and Deep Learning with Python

Machine and Deep Learning with Python Education Tutorials and courses Supervised learning superstitions cheat sheet Introduction to Deep Learning with Python How to implement a neural network How to build and run your first deep learning network Neur

Android自定义属性时format选项可以取用的值

1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name="名称"> <attr format="reference" name="background" /> </declare-styleable> (2)属性使用: <ImageView android:layout_width="42dip" android:layout_h

android自定义控件(三) 增加内容 自定义属性 format详解

转自 http://www.gisall.com/html/35/160435-5369.html 1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name = "名称"> <attr name = "background" format = "reference" /> </declare-styleable> (2)属性使用: <ImageView

window.onload和window.document.readystate的探究

在编写前端页面的时候,我们时常需要对页面加载的状态进行判断,以便进行相应的操作. 比如在移动端,时常需要在页面完全加载完成之前,先显示一个loading的图标,等待页面完成加载完成后,才显示出真正要展现的页面元素.见代码1: <html> <head> <script src="http://code.jquery.com/jquery-1.8.0.min.js"></script> <script> function isL

Android attrs.xml文件中属性类型format值的格式

"reference" //引用 "color" //颜色 "boolean" //布尔值 "dimension" //尺寸值 "float" //浮点值 "integer" //整型值 "string" //字符串 "fraction" //百分数,比如200% 枚举型的格式: < attr name="orientation&q

【转】declare-styleable的使用(自定义控件) 以及declare-styleable中format详解

原文网址:http://www.cnblogs.com/622698abc/p/3348692.html declare-styleable是给自定义控件添加自定义属性用的 1.首先,先写attrs.xml <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="TestAttr"> <attr name=&q

Android自定义属性format类型

1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name = "名称"> <attr name = "background" format = "reference" /> </declare-styleable> (2)属性使用: <ImageView android:layout_width = "42dip"         

Android自定义属性,format详解

博客园 博问 闪存 首页 新随笔 联系 管理 订阅 随笔- 90  文章- 6  评论- 57 Android自定义属性,format详解 1. reference:参考某一资源ID. (1)属性定义: <declare-styleable name = "名称"> <attr name = "background" format = "reference" /> </declare-styleable> (2