RxJS v6 dash 文档

栏目: 编程语言 · 发布时间: 7年前

内容简介:从

rxjs6.docset 成品下载地址

rxjs6.docset.zip

代码仓库

https://github.com/xinshangshangxin/dash-rxjs-6

原理

官方文档 Any HTML Documentation 可知, 只要有 HTML, 就可以轻松构建 Dash 文档

步骤

创建文件夹 <docset name>.docset/Contents/Resources/Documents/

创建 Info.plist 文件 和 icon.png

Info.plist 的模板 在 https://kapeli.com/resources/Info.plist

https://rxjs-dev.firebaseapp.com/api 解析有哪些 API

Network 中可以 看到 一个 /generated/docs/api/api-list.json 的请求, 里面有每个 API 内容, 如下图

RxJS v6 dash 文档

创建 SQLite Index

将上面 api-json 的内容 创建到 SQLite Index
CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);

创建 每个 API 的 html 界面

  • api-json 的内容中 有 path 属性, 可以请求每个界面的详细内容( content 属性)
    RxJS v6 dash 文档
  • ReactiveX/rxjs 的仓库中 发现 用了 assets/js/prettify.js 来格式化代码, 所以相同的, 在我们创建的 html 界面中需要 prettify 来格式化代码显示, 代码如下
let codeEleList = document.querySelectorAll('body code-example');
[...codeEleList].forEach((ele) => {
  let html = window.prettyPrintOne(ele.innerHTML, 'javascript', false);
  ele.innerHTML = `<aio-code>
  <pre class="prettyprint lang-javascript">
    <code class="animated fadeIn">${html}
    </code>
  </pre>
</aio-code>`;
});
  • 由于是离线文档, 所以在 html 中所有的地址都要转化成相对路径, 代码如下
let depth = location.href.replace(/.*\/api\//, '').split('/').length;
let aEleList = document.querySelectorAll('a');
[...aEleList].forEach((ele) => {
  let href = ele.href;
  if (/\/api\//.test(href)) {
    let depthStr = new Array(depth).fill('..').join('/');
    let [preUrl, anchor = ''] = href.split('#');
    ele.href = preUrl.replace(/.*\/api\//, `${depthStr}/api/`) + '.html' + '#' + anchor;
  }
});

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Design and Analysis of Distributed Algorithms (Wiley Series on P

Design and Analysis of Distributed Algorithms (Wiley Series on P

Nicola Santoro / Wiley-Interscience / 2006-10-27 / USD 140.95

This text is based on a simple and fully reactive computational model that allows for intuitive comprehension and logical designs. The principles and techniques presented can be applied to any distrib......一起来看看 《Design and Analysis of Distributed Algorithms (Wiley Series on P》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换