1 Star 0 Fork 0

bit212/TechDocs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

cover

TechDocs

The technical document curation service for you.

Chrome Extension

Easy switching between languages.

screenshot

Supported Documents

Check the list of sitefile.

We've just started the project. Pls let us know which document you need!

Sitefiles

Original Documents

The sitefile of the original document - typically written in English - would be like below. This example is a sitefile for Bootstrap.

{
  "id": "bootstrap",
  "title": "Bootstrap · The world's most popular mobile-first and responsive front-end framework.",
  "url": "http://getbootstrap.com",
  "language": "en",
  "contribute": "https://github.com/twbs/bootstrap",
  "version": "3.3.*"
}
  • id: The ID in TechDocs. It must be unique.
  • title: The title of the document.
  • url: The URL of the document. No trailing slash needed.
  • language: The language the document written in. en fr ja cn kr...
  • contribute: The URL for contributing to the document. Typically a GitHub repo.
  • version: The version of the product.

Translated Documents

Translated documents have two more attributes in sitefile.

{
  "id": "bootstrap-ja",
  "title": "Bootstrap · The world's most popular mobile-first and responsive front-end framework.",
  "url": "http://www.wivern.com/bootstrap",
  "language": "ja",
  "contribute": "https://twitter.com/smokyjp",
  "version": "3.2.*",
  "origin": "bootstrap",
  "rules": [
    "getting-started/ > getting-started.html",
    "css/ > css.html",
    "components/ > components.html"
  ]
}
  • origin: The ID of the original document.
  • rules: The list of pairs of URL. "[original] > [translated]"

Wildcard in URL

We can use wildcards in rules section.

"rules": [
  "getting-started/ > getting-started.html",
  "css/ > css.html",
  "components/ > components.html"
]

The part of sitefile above would be rewritten like below.

"rules": [
  "*/ > *.html"
]

How to Process Wildcard

A wildcard * will be replaced into RegExp (.+?) internally. The code below is a pseudo code for explanation.

var url1, url2;
var original = 'css/';
var translated = 'css.html';

url1 = original.replace(new RegExp('^(.+?)/$'), '$1.html');
// url1 == translated

url2 = translated.replace(new RegExp('^(.+?).html$'), '$1/');
// url2 == original

As above, wildcards are bidirectionally used - original to translate and vice versa.

Filter in URL

Sometimes, URLs need more complicated matching. For example, the case below needs camelCase <--> snake_case conversion.

Type URL
original (en) https://docs.angularjs.org/api/**ng/directive/ngBlur**
translated (ja) http://js.studio-kingdom.com/**angularjs/ng_directive/ng_blur**

The (part of) sitefile would be like below.

"rules": [
  "ng/* > ng_* | camel2snake"
]

The pipe | can connect single of multiple filters.

  • camel2snake: convert camelCase to snake_case
  • snake2camel: convert snake_case to camelCase
  • dot2snake: convert dot.case to snake_case
  • snake2dot: convert snake_case to dot.case
  • replace: convert letters to others

Reversibility

Wildcards and filters are useful, but it's possible to break the reversibility of URL conversion. Please note that we have to match original <--> translated.

Basically we should keep reversibility. If it couldn't, we have reverse match. The next two are equivalent.

"rules": [
  "ng/* > ng_* | camel2snake",
  "ng/* < ng_* | snake2camel"
]

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/bit212/TechDocs.git
git@gitee.com:bit212/TechDocs.git
bit212
TechDocs
TechDocs
css-preprocess

搜索帮助