-
-
Notifications
You must be signed in to change notification settings - Fork 53
Development
Update
- 2020-04-01: update for Vivliostyle.js v2.0.0
- 2019-12-17: Vivliostyle 2020 Project
- 2019-10-08: Change directory structure
- 2019-08-05: JS-to-TS migration - Vivliostyle.js changed its type check system from Google Closure Compiler to TypeScript.
Similar documents:
-
Contribution Guide in https://docs.vivliostyle.org
- Almost same as this document, but Japanese version exists.
-
CONTRIBUTING.md in this repository
- Subset version of Contribution Guide.
Vivliostyle.js consists of two components:
Core | Viewer |
---|---|
Vivliostyle.js Core layout engine | Vivliostyle.js Viewer UI |
Make sure that the following is installed:
Clone vivliostyle.js.
git clone https://github.com/vivliostyle/vivliostyle.js.git
cd vivliostyle.js
@vivliostyle/core
is listed as a dependency for @vivliostyle/viewer in package.json
. During development, you want to use the local copy of @vivliostyle/core
, rather than a package installed from npm. For this purpose, use yarn bootstrap
to make a symbolic link:
yarn install # install dependencies
yarn bootstrap # setup development environment
yarn build-dev # build a development version of both Core and Viewer.
yarn dev # start watching source files and open browser.
With yarn dev
, a web server starts (Browsersync with live-reload enabled), and Google Chrome should automatically open. If no browser opens, open http://localhost:3000/core/test/files/. On saving any source file, the browser automatically reloads.
Viewer HTML file (in development mode) is located at packages/viewer/lib/vivliostyle-viewer-dev.html
. You can open an (X)HTML file with a URL (relative to the viewer HTML file) specified to #src=
hash parameter. For example, http://localhost:3000/viewer/lib/vivliostyle-viewer-dev.html#src=../../core/test/files/print_media/index.html opens a test file for print media located at packages/core/test/files/print_media/index.html
.
Test HTML files, intended to be used during development, are located at packages/core/test/files/
. You are encouraged to add test files useful for implementing and verifying features.
The packages/core/scripts/package-artifacts/samples/
directory holds sample files for testing. See Vivliostyle Samples for more samples.
The TypeScript source files are compiled and minified by Rollup. To build the minified version of JavaScript files, run yarn build
(in the repository root directory). The sources are type-checked and the minified file will be generated under packages/core/lib/
and packages/viewer/lib
directories.
Jasmine is used for unit testing. Spec files are located under packages/core/test/spec/
. To run unit tests on a local machine, run yarn test
.
The unit tests is automatically invoked in Travis CI when pushing to GitHub. When pushed to master, after all tests pass, the code will be automatically deployed as the Canary release so please be careful when pushing to master (merging PR).
In development mode (yarn dev
), you can debug Vivliostyle.js with TypeScript source code in your browser's DevTools.
Run yarn lint
for lint and code formatting (using ESLint with eslint-plugin-prettier).
Run yarn format
for code formatting with prettier.
Before proceeding with the release process, run the following code to ensure that a production build has been created.
yarn lint
yarn test
yarn clean
yarn build
Run yarn version:prerelease
to create pre-release. And run yarn version:bump
to increment pre-release count.
If current version is pre-release (e.g. v2.0.0-pre.4), run:
yarn version:graduate
To bump up version from stable version to stable version (e.g. v2.0.0 -> v2.0.1):
yarn version:bump
- Match class name and its file name for consistency.
- Use PascalCase for module import name, kebab-case for a file name, making easier to visually distinguish differences.
- No abbreviation in a file name and class name for perspicuity, except:
- Initialism (EPUB, PDF, etc).
- Lengthy name (prefer conditional-props over conditional-properties).
All notable changes to this project will be documented in CHANGELOG.md
.
See Conventional Commits for commit guidelines.
This occurs after yarn add
. Run lerna link
to recreate symlinks after the installation, otherwise use lerna add
instead of yarn add
.
Please update the following documents as developing.
-
CHANGELOG.md
- Automatically generated with Conventional Commits.
-
Supported CSS Features
- Document about CSS features (values, selectors, at-rules, media queries and properties) supported by Vivliostyle.
Source files under packages/core/src/
are briefly described below.
- Exposed interface of vivliostyle-core. To use vivliostyle-core, instantiate Vivliostyle.CoreViewer, set options, register event listeners by addListener method, and call loadDocument or loadPublication method.
- Defines constants used throughout the library.
- Task scheduling.
- Definitions for expressions of Adaptive Layout.
- Definitions for various CSS values.
- CSS parser.
- Classes for selector matching and cascading calculation.
- View tree data structures.
- Apply CSS cascade to a document incrementally.
- Web font handling.
- Classes for page masters of Adaptive Layout.
- Page floats.
- Generation of view tree.
- Content layout inside regions, including column breaking etc.
- Support for CSS Paged Media.
- Select page master, layout regions (columns) one by one etc.
- Handling EPUB metadata, rendering pages etc.
(There are more files... See the
pakcages/core/src
directory)