Skip to content

Commit 71351d3

Browse files
Clean up the docs
1 parent 54f3a44 commit 71351d3

File tree

2 files changed

+48
-40
lines changed

2 files changed

+48
-40
lines changed

flatpak-builder/dist/index.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class Configuration {
8080
}
8181

8282
/**
83-
* Start a D-Bus session and return the process and address.
83+
* Start a D-Bus session and return the process and the D-Bus address.
84+
*
8485
* @returns {Promise}
8586
*/
8687
const startDBusSession = () => {
@@ -101,12 +102,13 @@ const startDBusSession = () => {
101102
}
102103

103104
/**
104-
* Compute a SHA-256 hash of the manifest file.
105-
* @param {PathLike} manifestPath
105+
* Compute a SHA-256 hash of a file.
106+
*
107+
* @param {PathLike} path The file path.
106108
*/
107-
const computeHash = async (manifestPath) => {
109+
const computeHash = async (path) => {
108110
const hash = crypto.createHash('sha256')
109-
const stream = await fs.readFile(manifestPath)
111+
const stream = await fs.readFile(path)
110112

111113
const buffer = Buffer.alloc(stream.byteLength)
112114
for (let i = 0; i < buffer.length; i++) {
@@ -118,10 +120,10 @@ const computeHash = async (manifestPath) => {
118120
}
119121

120122
/**
121-
* Parses a flatpak manifest and returns it as a JS object
122-
* It supports both supported file formats by flatpak-builder: JSON & YAML.
123+
* Parses a Flatpak manifest
123124
*
124-
* @param {PathLike} manifestPath the relative/absolute path to the manifest
125+
* @param {PathLike} manifestPath The path to the manifest
126+
* @returns {object} The manifest
125127
*/
126128
const parseManifest = async (manifestPath) => {
127129
const data = await fs.readFile(manifestPath)
@@ -145,9 +147,9 @@ const parseManifest = async (manifestPath) => {
145147
/**
146148
* Saves a manifest as a YAML or JSON file
147149
*
148-
* @param {object} manifest A flatpak manifest
150+
* @param {object} manifest A Flatpak manifest
149151
* @param {PathLike} dest Where to save the flatpak manifest
150-
* @returns {object} manifest
152+
* @returns {object} The manifest
151153
*/
152154
const saveManifest = async (manifest, dest) => {
153155
let data = null
@@ -169,13 +171,14 @@ const saveManifest = async (manifest, dest) => {
169171
}
170172

171173
/**
174+
* Modify the manifest to prepare it for tests.
175+
*
172176
* Applies the following changes to the original manifest:
173-
* 1 - If tests are enabled, proper test-args are added
174-
* to enable network & x11 access.
177+
* - Add test-args are to enable network & x11 access.
175178
*
176-
* @param {Object} manifest the parsed manifest
177-
* @param {boolean} runTests whether to run tests or not
178-
* @param {Object} testEnv dictionary of environment variables
179+
* @param {Object} manifest The parsed manifest
180+
* @param {boolean} runTests Whether to run tests or not
181+
* @param {Object} testEnv Dictionary of environment variables
179182
* @returns {object} The modified manifest
180183
*/
181184
const modifyManifest = (manifest, runTests = false, testEnv = {}) => {
@@ -203,10 +206,10 @@ const modifyManifest = (manifest, runTests = false, testEnv = {}) => {
203206
}
204207

205208
/**
206-
* Build the flatpak & create a bundle from the build
209+
* Build the Flatpak & create a bundle from the build
207210
*
208-
* @param {object} manifest A flatpak manifest
209-
* @param {PathLike} manifestPath The flatpak manifest path
211+
* @param {object} manifest A Flatpak manifest
212+
* @param {PathLike} manifestPath The Flatpak manifest path
210213
* @param {string} cacheHitKey The key used to restore the build directory
211214
* @param {Configuration} config The build configuration
212215
*/
@@ -267,8 +270,9 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
267270

268271
/**
269272
* Initialize the build
270-
* It consists mostly of setting up the flatpak remote if one other than the default is set
271-
* along with restoring the cache from the latest build
273+
*
274+
* Consists of setting up the Flatpak remote if one other than the default is set
275+
* and restoring the cache from the latest build
272276
*
273277
* @param {Configuration} config The build configuration
274278
* @returns {Promise<String>} The cacheHitKey if a cache was hit

flatpak-builder/index.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ class Configuration {
7474
}
7575

7676
/**
77-
* Start a D-Bus session and return the process and address.
77+
* Start a D-Bus session and return the process and the D-Bus address.
78+
*
7879
* @returns {Promise}
7980
*/
8081
const startDBusSession = () => {
@@ -95,12 +96,13 @@ const startDBusSession = () => {
9596
}
9697

9798
/**
98-
* Compute a SHA-256 hash of the manifest file.
99-
* @param {PathLike} manifestPath
99+
* Compute a SHA-256 hash of a file.
100+
*
101+
* @param {PathLike} path The file path.
100102
*/
101-
const computeHash = async (manifestPath) => {
103+
const computeHash = async (path) => {
102104
const hash = crypto.createHash('sha256')
103-
const stream = await fs.readFile(manifestPath)
105+
const stream = await fs.readFile(path)
104106

105107
const buffer = Buffer.alloc(stream.byteLength)
106108
for (let i = 0; i < buffer.length; i++) {
@@ -112,10 +114,10 @@ const computeHash = async (manifestPath) => {
112114
}
113115

114116
/**
115-
* Parses a flatpak manifest and returns it as a JS object
116-
* It supports both supported file formats by flatpak-builder: JSON & YAML.
117+
* Parses a Flatpak manifest
117118
*
118-
* @param {PathLike} manifestPath the relative/absolute path to the manifest
119+
* @param {PathLike} manifestPath The path to the manifest
120+
* @returns {object} The manifest
119121
*/
120122
const parseManifest = async (manifestPath) => {
121123
const data = await fs.readFile(manifestPath)
@@ -139,9 +141,9 @@ const parseManifest = async (manifestPath) => {
139141
/**
140142
* Saves a manifest as a YAML or JSON file
141143
*
142-
* @param {object} manifest A flatpak manifest
144+
* @param {object} manifest A Flatpak manifest
143145
* @param {PathLike} dest Where to save the flatpak manifest
144-
* @returns {object} manifest
146+
* @returns {object} The manifest
145147
*/
146148
const saveManifest = async (manifest, dest) => {
147149
let data = null
@@ -163,13 +165,14 @@ const saveManifest = async (manifest, dest) => {
163165
}
164166

165167
/**
168+
* Modify the manifest to prepare it for tests.
169+
*
166170
* Applies the following changes to the original manifest:
167-
* 1 - If tests are enabled, proper test-args are added
168-
* to enable network & x11 access.
171+
* - Add test-args are to enable network & x11 access.
169172
*
170-
* @param {Object} manifest the parsed manifest
171-
* @param {boolean} runTests whether to run tests or not
172-
* @param {Object} testEnv dictionary of environment variables
173+
* @param {Object} manifest The parsed manifest
174+
* @param {boolean} runTests Whether to run tests or not
175+
* @param {Object} testEnv Dictionary of environment variables
173176
* @returns {object} The modified manifest
174177
*/
175178
const modifyManifest = (manifest, runTests = false, testEnv = {}) => {
@@ -197,10 +200,10 @@ const modifyManifest = (manifest, runTests = false, testEnv = {}) => {
197200
}
198201

199202
/**
200-
* Build the flatpak & create a bundle from the build
203+
* Build the Flatpak & create a bundle from the build
201204
*
202-
* @param {object} manifest A flatpak manifest
203-
* @param {PathLike} manifestPath The flatpak manifest path
205+
* @param {object} manifest A Flatpak manifest
206+
* @param {PathLike} manifestPath The Flatpak manifest path
204207
* @param {string} cacheHitKey The key used to restore the build directory
205208
* @param {Configuration} config The build configuration
206209
*/
@@ -261,8 +264,9 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
261264

262265
/**
263266
* Initialize the build
264-
* It consists mostly of setting up the flatpak remote if one other than the default is set
265-
* along with restoring the cache from the latest build
267+
*
268+
* Consists of setting up the Flatpak remote if one other than the default is set
269+
* and restoring the cache from the latest build
266270
*
267271
* @param {Configuration} config The build configuration
268272
* @returns {Promise<String>} The cacheHitKey if a cache was hit

0 commit comments

Comments
 (0)