Merge pull request #9520 from lutzhelm/iiif-doc

[WIP] Improve IIIF tile source and parser documentation
This commit is contained in:
Tim Schaub
2019-05-13 06:47:09 -06:00
committed by GitHub
2 changed files with 16 additions and 6 deletions
+11 -6
View File
@@ -97,9 +97,10 @@ import {assert} from '../asserts.js';
*/ */
/** /**
* @enum {string} * Enum representing the major IIIF Image API versions
*/ * @enum {string}
export const Versions = { */
const Versions = {
VERSION1: 'version1', VERSION1: 'version1',
VERSION2: 'version2', VERSION2: 'version2',
VERSION3: 'version3' VERSION3: 'version3'
@@ -275,7 +276,7 @@ versionFunctions[Versions.VERSION3] = generateVersion3Options;
class IIIFInfo { class IIIFInfo {
/** /**
* @param {ImageInformationResponse1_0|ImageInformationResponse1_1|ImageInformationResponse2|ImageInformationResponse3|string} imageInfo * @param {string|ImageInformationResponse1_0|ImageInformationResponse1_1|ImageInformationResponse2|ImageInformationResponse3} imageInfo
* Deserialized image information JSON response object or JSON response as string * Deserialized image information JSON response object or JSON response as string
*/ */
constructor(imageInfo) { constructor(imageInfo) {
@@ -283,8 +284,9 @@ class IIIFInfo {
} }
/** /**
* @param {Object|string} imageInfo Deserialized image information JSON response * @param {string|ImageInformationResponse1_0|ImageInformationResponse1_1|ImageInformationResponse2|ImageInformationResponse3} imageInfo
* object or JSON response as string * Deserialized image information JSON response object or JSON response as string
* @api
*/ */
setImageInfo(imageInfo) { setImageInfo(imageInfo) {
if (typeof imageInfo == 'string') { if (typeof imageInfo == 'string') {
@@ -296,6 +298,7 @@ class IIIFInfo {
/** /**
* @returns {Versions} Major IIIF version. * @returns {Versions} Major IIIF version.
* @api
*/ */
getImageApiVersion() { getImageApiVersion() {
if (this.imageInfo === undefined) { if (this.imageInfo === undefined) {
@@ -394,6 +397,7 @@ class IIIFInfo {
/** /**
* @param {PreferredOptions} opt_preferredOptions Optional options for preferred format and quality. * @param {PreferredOptions} opt_preferredOptions Optional options for preferred format and quality.
* @returns {import("../source/IIIF.js").Options} IIIF tile source ready constructor options. * @returns {import("../source/IIIF.js").Options} IIIF tile source ready constructor options.
* @api
*/ */
getTileSourceOptions(opt_preferredOptions) { getTileSourceOptions(opt_preferredOptions) {
const options = opt_preferredOptions || {}, const options = opt_preferredOptions || {},
@@ -424,3 +428,4 @@ class IIIFInfo {
} }
export default IIIFInfo; export default IIIFInfo;
export {Versions};
+5
View File
@@ -56,6 +56,11 @@ function formatPercentage(percentage) {
*/ */
class IIIF extends TileImage { class IIIF extends TileImage {
/**
* @param {Options} opt_options Tile source options. Use {@link import("../format/IIIFInfo.js").IIIFInfo}
* to parse Image API service information responses into constructor options.
* @api
*/
constructor(opt_options) { constructor(opt_options) {
const options = opt_options || {}; const options = opt_options || {};