Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Reject documentation comments

Manav Rathi82f253d9fe87
diff --git a/.github/checks/documentation-comments/check.mjs b/.github/checks/documentation-comments/check.mjs
new file mode 100644
index 0000000000..aa8986ec03
--- /dev/null
+++ b/.github/checks/documentation-comments/check.mjs
@@ -0,0 +1,135 @@
+import { execFileSync } from "node:child_process";
+import { existsSync, readFileSync } from "node:fs";
+import { extname, resolve } from "node:path";
+
+const root = resolve(process.argv[2] ?? ".");
+const extensions = new Set([
+ ".c",
+ ".cc",
+ ".cjs",
+ ".cpp",
+ ".css",
+ ".dart",
+ ".gradle",
+ ".h",
+ ".java",
+ ".js",
+ ".jsx",
+ ".kt",
+ ".kts",
+ ".less",
+ ".mjs",
+ ".rs",
+ ".sass",
+ ".scss",
+ ".swift",
+ ".ts",
+ ".tsx",
+]);
+const paths = git(
+ "ls-files",
+ "--cached",
+ "--others",
+ "--exclude-standard",
+ "-z",
+)
+ .split("\0")
+ .filter((path) => path && extensions.has(extname(path)) && existsSync(resolve(root, path)));
+
+if (!paths.length) throw new Error(`${root}: found no source files`);
+
+for (const path of paths) {
+ const source = readFileSync(resolve(root, path), "utf8");
+ if (isGenerated(source)) continue;
+ const clap = path.endsWith(".rs") ? clapRanges(source) : [];
+ for (const comment of documentationComments(source)) {
+ if (isToolInput(path, comment.text)) continue;
+ if (clap.some(([start, end]) => comment.line >= start && comment.line <= end)) continue;
+ console.error(
+ `${path}:${comment.line}: documentation comment; use an ordinary comment if needed`,
+ );
+ process.exitCode = 1;
+ }
+}
+
+function git(...args) {
+ return execFileSync("git", args, {
+ cwd: root,
+ encoding: "utf8",
+ maxBuffer: 10 * 1024 * 1024,
+ });
+}
+
+function documentationComments(source) {
+ const comments = [];
+ const lines = source.split("\n");
+ for (let i = 0; i < lines.length; i++) {
+ if (/^\s*(?:\/\/\/|\/\/!)/.test(lines[i])) {
+ const start = i;
+ while (i < lines.length - 1 && /^\s*(?:\/\/\/|\/\/!)/.test(lines[i + 1])) i++;
+ comments.push({ line: start + 1, text: lines.slice(start, i + 1).join("\n") });
+ continue;
+ }
+ if (!/^\s*\/\*(?:\*|!)/.test(lines[i])) continue;
+ const start = i;
+ while (i < lines.length && !lines[i].includes("*/")) i++;
+ comments.push({ line: start + 1, text: lines.slice(start, i + 1).join("\n") });
+ }
+ return comments;
+}
+
+function isToolInput(path, comment) {
+ const extension = extname(path);
+ if (![".cjs", ".js", ".jsx", ".mjs", ".ts", ".tsx"].includes(extension)) return false;
+ if (
+ comment
+ .split("\n")
+ .every((line) =>
+ /^\s*\/\/\/\s*<(?:reference|amd-(?:module|dependency))\b[^>]*\/>\s*$/.test(
+ line,
+ ),
+ )
+ ) {
+ return true;
+ }
+ if ([".ts", ".tsx"].includes(extension)) return false;
+ return (
+ /^\s*\/\*\*\s*@param\s+\{[^\n]+\}\s+\S+\s*\*\/\s*$/.test(comment) ||
+ /^\s*\/\*\*\s*@(satisfies|type)\s+\{[^\n]+\}\s*\*\/\s*$/.test(comment)
+ );
+}
+
+function isGenerated(source) {
+ return /^\s*(?:\/\/+|\/\*+|\*)\s*(?:@generated\b|.*\bgenerated\b.*\bdo not (?:edit|modify)\b)/im.test(
+ source.split("\n").slice(0, 12).join("\n"),
+ );
+}
+
+function clapRanges(source) {
+ const lines = source.split("\n");
+ const ranges = [];
+ for (let i = 0; i < lines.length; i++) {
+ if (!/#\s*\[\s*derive\s*\(/.test(lines[i])) continue;
+ const start = i;
+ let derive = lines[i];
+ while (i < lines.length - 1 && !derive.includes(")]")) derive += `\n${lines[++i]}`;
+ if (!/\b(?:Args|Parser|Subcommand)\b/.test(derive)) continue;
+ let declaration = i + 1;
+ while (declaration < lines.length && !/\b(?:struct|enum)\s+\w+/.test(lines[declaration])) {
+ declaration++;
+ }
+ let depth = 0;
+ let opened = false;
+ for (let end = declaration; end < lines.length; end++) {
+ const code = lines[end].replace(/\/\/.*$/, "");
+ depth += (code.match(/{/g) ?? []).length;
+ if (depth) opened = true;
+ depth -= (code.match(/}/g) ?? []).length;
+ if (!opened || depth) continue;
+ ranges.push([start + 1, end + 1]);
+ i = end;
+ break;
+ }
+ }
+ return ranges;
+}
diff --git a/.github/checks/documentation-comments/test.mjs b/.github/checks/documentation-comments/test.mjs
new file mode 100644
index 0000000000..cc7d089cc3
--- /dev/null
+++ b/.github/checks/documentation-comments/test.mjs
@@ -0,0 +1,141 @@
+import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { dirname, join } from "node:path";
+
+const check = join(import.meta.dirname, "check.mjs");
+
+let result = run(
+ {
+ "rust/lib.rs": "//! Module documentation.\npub fn value() {}\n",
+ "mobile/value.dart": "/// API documentation.\nclass Value {}\n",
+ "android/Value.kt": "/** API documentation. */\nclass Value\n",
+ "native/value.h": "/** API documentation. */\nint value(void);\n",
+ "web/value.ts": "/** API documentation. */\nexport const value = 1;\n",
+ "styles/value.scss": "/** API documentation. */\n.value {}\n",
+ "styles/value.css": "/** API documentation. */\n.value {}\n",
+ "build/plugin.gradle": "/// API documentation.\n",
+ "gen/value.ts": "/** A path alone does not mark a file as generated. */\n",
+ "web/reference.ts": [
+ '/// <reference types="vite/client" />',
+ "/// API documentation.",
+ ].join("\n"),
+ "web/config.js": [
+ "/** @param {string} value",
+ " * API documentation.",
+ " */",
+ "function configure(value) {}",
+ ].join("\n"),
+ "web/type.js": "/** @type {string} API documentation. */\nconst value = '';\n",
+ "web/type.ts": "/** @type {string} */\nconst value = '';\n",
+ "web/param.js": "/** @param {string} */\nfunction configure(value) {}\n",
+ "web/satisfies.js": [
+ "/** @satisfies {Record<string, string>}",
+ " * API documentation.",
+ " */",
+ "const values = {};",
+ ].join("\n"),
+ "rust/clap.rs": [
+ "#[derive(clap::Parser)]",
+ "struct Args {",
+ " /// Printed in command help.",
+ " json: bool,",
+ "}",
+ "/// API documentation.",
+ "pub fn value() {}",
+ ].join("\n"),
+ "deleted.rs": "/// Deleted documentation.\n",
+ },
+ {
+ "native/Value.swift": "/// API documentation.\nstruct Value {}\n",
+ },
+ ["deleted.rs"],
+);
+assert.equal(result.status, 1, result.stderr);
+for (const path of [
+ "rust/lib.rs:1",
+ "mobile/value.dart:1",
+ "android/Value.kt:1",
+ "native/value.h:1",
+ "web/value.ts:1",
+ "styles/value.scss:1",
+ "styles/value.css:1",
+ "build/plugin.gradle:1",
+ "gen/value.ts:1",
+ "web/reference.ts:1",
+ "web/config.js:1",
+ "web/type.js:1",
+ "web/type.ts:1",
+ "web/param.js:1",
+ "web/satisfies.js:1",
+ "rust/clap.rs:6",
+ "native/Value.swift:1",
+]) {
+ assert.match(result.stderr, new RegExp(path.replace(".", "\\.")));
+}
+assert.doesNotMatch(result.stderr, /deleted/);
+assert.doesNotMatch(result.stderr, /rust\/clap\.rs:3/);
+
+result = run({
+ "rust/local.rs": "// Non-obvious implementation reason.\npub fn value() {}\n",
+ "rust/args.rs": [
+ "#[derive(clap::Parser)]",
+ "pub struct Args {",
+ " /// Printed in command help.",
+ " pub json: bool,",
+ "}",
+ ].join("\n"),
+ "web/env.d.ts": '/// <reference types="vite/client" />\n',
+ "web/config.js": [
+ '/** @param {import("webpack").Compiler} compiler */',
+ "function configure(compiler) {}",
+ '/** @type {import("next").NextConfig} */',
+ "const config = {};",
+ "/** @satisfies {Record<string, string>} */",
+ "const values = {};",
+ ].join("\n"),
+ "generated/value.dart": [
+ "// Generated file. Do not edit.",
+ "/// Generated documentation.",
+ "class Value {}",
+ ].join("\n"),
+ "mobile/value.g.dart": [
+ "// Generated code. Do not modify.",
+ "/// Generated documentation.",
+ "class Value {}",
+ ].join("\n"),
+});
+assert.equal(result.status, 0, result.stderr);
+assert.equal(result.stdout, "");
+assert.equal(result.stderr, "");
+
+result = run({ ".gitignore": "" });
+assert.notEqual(result.status, 0, result.stderr);
+assert.match(result.stderr, /found no source files/);
+
+function run(tracked, untracked = {}, deleted = []) {
+ const root = mkdtempSync(join(tmpdir(), "ente-documentation-comments-"));
+ try {
+ spawn("git", ["init", "-q"], root);
+ for (const [path, content] of Object.entries(tracked)) write(root, path, content);
+ spawn("git", ["add", "."], root);
+ for (const path of deleted) rmSync(join(root, path));
+ for (const [path, content] of Object.entries(untracked)) write(root, path, content);
+ return spawn(process.execPath, [check, root]);
+ } finally {
+ rmSync(root, { recursive: true });
+ }
+}
+
+function write(root, path, content) {
+ const target = join(root, path);
+ mkdirSync(dirname(target), { recursive: true });
+ writeFileSync(target, content);
+}
+
+function spawn(command, args, cwd) {
+ const result = spawnSync(command, args, { cwd, encoding: "utf8" });
+ assert.equal(result.error, undefined);
+ return result;
+}
diff --git a/.github/checks/run.sh b/.github/checks/run.sh
new file mode 100755
index 0000000000..bac82c9b29
--- /dev/null
+++ b/.github/checks/run.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+cd "$(dirname "$0")/../.."
+
+node .github/checks/documentation-comments/check.mjs
+node .github/checks/documentation-comments/test.mjs
diff --git a/.github/workflows/repo-lint.yml b/.github/workflows/repo-lint.yml
new file mode 100644
index 0000000000..21dcdec289
--- /dev/null
+++ b/.github/workflows/repo-lint.yml
@@ -0,0 +1,20 @@
+name: "Lint (Repo)"
+
+on:
+ pull_request:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
+
+ - run: .github/checks/run.sh
diff --git a/mobile/apps/photos/plugins/ente_photos_platform/lib/src/device_trash.dart b/mobile/apps/photos/plugins/ente_photos_platform/lib/src/device_trash.dart
index 71dbe871bc..209904784d 100644
--- a/mobile/apps/photos/plugins/ente_photos_platform/lib/src/device_trash.dart
+++ b/mobile/apps/photos/plugins/ente_photos_platform/lib/src/device_trash.dart
@@ -17,7 +17,7 @@ class DeviceTrashFile {
final int localID;
- /// The absolute deletion deadline in microseconds since the Unix epoch.
+ // The absolute deletion deadline in microseconds since the Unix epoch.
final int deleteBy;
final String deviceFolder;
diff --git a/mobile/apps/photos/plugins/media_extension/android/src/main/kotlin/io/ente/photos/media_extension/MediaExtensionPlugin.kt b/mobile/apps/photos/plugins/media_extension/android/src/main/kotlin/io/ente/photos/media_extension/MediaExtensionPlugin.kt
index 73775cc9ab..c8267a8e6d 100644
--- a/mobile/apps/photos/plugins/media_extension/android/src/main/kotlin/io/ente/photos/media_extension/MediaExtensionPlugin.kt
+++ b/mobile/apps/photos/plugins/media_extension/android/src/main/kotlin/io/ente/photos/media_extension/MediaExtensionPlugin.kt
@@ -33,14 +33,9 @@ internal fun isMediaStorePendingItemError(message: String?): Boolean {
return message?.contains(MediaStorePendingItemErrorPrefix, ignoreCase = true) == true
}
-/// The Class which implements Activity Aware FlutterPlugin
class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
PluginRegistry.ActivityResultListener, PluginRegistry.NewIntentListener {
- /// The MethodChannel that will the communication between Flutter and native Android
- ///
- /// This local reference serves to register the plugin with the Flutter Engine and unregister it
- /// when the Flutter Engine is detached from the Activity
private lateinit var methodChannel: MethodChannel
private lateinit var context: Context
private var activity: Activity? = null
@@ -49,7 +44,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
private val ioExecutor: ExecutorService = Executors.newSingleThreadExecutor()
private val logTag = "EnteMediaExtension"
- ///ENUM of all the possible IntentAction for a gallery app.
enum class IntentAction {
MAIN,
PICK,
@@ -57,20 +51,14 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
VIEW
}
- /// The Method invoked when FlutterEngine is attached to the app
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
- ///Application context is assigned to variable context
context = flutterPluginBinding.applicationContext
- ///Method Channel instance is created for channel [media_extension]
methodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "media_extension")
- /// Method Channel handler which handles all the methods
- /// invoked from flutter thread
methodChannel.setMethodCallHandler(this)
}
- /// The Method invoked when a methodCall is executed from flutter thread
override fun onMethodCall(call: MethodCall, result: Result) {
when (call.method) {
"getPlatformVersion" -> {
@@ -106,11 +94,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
}
}
- /// The Method is triggered by the Flutter thread with arguments containing
- /// and [uri] of the received media of type content://xyz.
- /// MediaStore/file image URIs are passed through directly so callers can
- /// render them without base64 overhead. Other image content providers keep
- /// the base64 fallback for compatibility with transient grants.
private fun getResolvedContent(
contentUri: Uri,
contentType: String,
@@ -151,6 +134,7 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
if (contentType.startsWith("video")) {
resolvedContent["data"] = contentUri.toString()
} else if (contentType.startsWith("image")) {
+ // Preserve transient-provider images after their URI grant expires.
resolvedContent["data"] = if (contentUri.canBeRenderedFromUri()) {
contentUri.toString()
} else {
@@ -224,8 +208,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
}
- /// The Method is triggered when the app is opened and it sends the [intent-action]
- /// and [uri] information in a HashMap Structure to the Flutter thread.
private fun emitIntentAction(intent: Intent) {
Handler(Looper.getMainLooper()).post {
methodChannel.invokeMethod("getIntentAction", getIntentAction(intent))
@@ -276,9 +258,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
return result
}
- /// The Method is triggered by the Flutter thread with arguments containing
- /// and [uri] of the selected image and sends the image to the requested app
- /// via RESULT_ACTION Intent using Content Provider
private fun setResult(call: MethodCall, result: Result) {
val uri = call.argument<String>("uri")?.let { Uri.parse(it) }
if (uri == null) {
@@ -429,9 +408,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
}
}
- /// The Method is triggered by the Flutter thread with arguments containing
- /// and [uri] of the selected image and sends the image to the chosen app
- /// which can handle the `ACTION_ATTACH_DATA` Intent
private fun setAs(call: MethodCall, result: Result) {
val title = "Set as"
val uri = call.argument<String>("uri")?.let { Uri.parse(it) }
@@ -448,9 +424,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
result.success(started)
}
- /// The Method is triggered by the Flutter thread with arguments containing
- /// and [uri] of the selected image and sends the image to the chosen app
- /// which can handle the `ACTION_VIEW` Intent
private fun openWith(call: MethodCall, result: Result) {
val title = call.argument<String>("title")
val uri = call.argument<String>("uri")?.let { Uri.parse(it) }
@@ -468,9 +441,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
result.success(started)
}
- /// The Method is triggered by the Flutter thread with arguments containing
- /// and [uri] of the selected image and sends the image to the chosen app
- /// which can handle the `ACTION_EDIT` Intent
private fun edit(call: MethodCall, result: Result) {
val title = call.argument<String>("title")
val uri = call.argument<String>("uri")?.let { Uri.parse(it) }
@@ -488,8 +458,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
result.success(started)
}
- /// The Method is creates content of the file which needs to be shared to
- /// other app using content resolver.
private fun getShareableUri(context: Context, uri: Uri): Uri? {
/* https://developer.android.com/training/secure-file-sharing/setup-sharing.html
https://developer.android.com/training/secure-file-sharing/setup-sharing.html
@@ -508,8 +476,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
}
}
- /// The Method is used to list out all the available apps
- /// which can handle the Supplied Intent Action.
private fun safeStartActivityChooser(title: String?, intent: Intent): Boolean {
if (activity?.let { intent.resolveActivity(it.packageManager) } == null) {
Log.i(logTag, " intent=$intent resolved activity return null")
@@ -539,8 +505,6 @@ class MediaExtensionPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
ioExecutor.shutdown()
}
- /// The Method Invoked after the Plugin is attached to Flutter engine
- /// Provides the activity context of the application
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
activityBinding = binding
activity = binding.activity
diff --git a/mobile/apps/photos/plugins/media_extension/lib/media_extension.dart b/mobile/apps/photos/plugins/media_extension/lib/media_extension.dart
index 95f3a0373b..815339beda 100644
--- a/mobile/apps/photos/plugins/media_extension/lib/media_extension.dart
+++ b/mobile/apps/photos/plugins/media_extension/lib/media_extension.dart
@@ -3,7 +3,6 @@ import 'dart:typed_data';
import 'package:media_extension/media_extension_action_types.dart';
import 'package:media_extension/media_extension_platform_interface.dart';
-/// Class which contains all the methods of the plugin
class MediaExtension {
Future<String?> getPlatformVersion() =>
MediaExtensionPlatform.instance.getPlatformVersion();
diff --git a/mobile/apps/photos/plugins/media_extension/lib/media_extension_action_types.dart b/mobile/apps/photos/plugins/media_extension/lib/media_extension_action_types.dart
index f8baf4dea5..56b49406b9 100644
--- a/mobile/apps/photos/plugins/media_extension/lib/media_extension_action_types.dart
+++ b/mobile/apps/photos/plugins/media_extension/lib/media_extension_action_types.dart
@@ -1,40 +1,9 @@
-/// The Enum represents the IntentAction which as invoked the app.
-///
-/// * main: invoked normally by user
-/// * pick: invoked by other app with ACTION_PICK Intent
-/// * edit: invoked by other app with ACTION_EDIT Intent
-/// * view: invoked by other app with ACTION_VIEW Intent
-/// * unknown: when unexpected case as occured
enum IntentAction { main, pick, edit, view, unknown }
-/// Method which extracts the value of the IntentAction as a string
-///
-/// Example:
-/// ```dart
-/// IntentAction action = IntentAction.main
-/// print(action.toShortString());
-/// ```
-/// Output:
-/// ```bash
-/// pick
-/// ```
extension ParseToString on IntentAction {
String toShortString() => toString().split('.').last;
}
-/// * Method which converts the string value to the IntentAction
-/// * Used for converting the string from native code to dart type
-///
-/// Example:
-/// ```dart
-/// String actionString = 'MAIN'
-/// IntentAction action = actionParser(actionString);
-/// print(action);
-/// ```
-/// Output:
-/// ```bash
-/// intentAction.main
-/// ```
IntentAction actionParser(String actionString) {
IntentAction? action;
@@ -55,9 +24,6 @@ IntentAction actionParser(String actionString) {
return action;
}
-/// MediaExtensionAction is custom data class
-/// * IntentAction action: Intent Action Which Invoked the app.
-/// * String uri: uri passed via the Intent.
class MediaExtentionAction {
final IntentAction? action;
final String? data;
@@ -76,25 +42,8 @@ class MediaExtentionAction {
});
}
-/// The Enum represents the MediaType of uri which as invoked the app.
-///
-/// * video
-/// * image
enum MediaType { video, image }
-/// * Method which converts the string value to the MediaType
-/// * Used for converting the string from native code to dart type
-///
-/// Example:
-/// ```dart
-/// String actionString = 'video'
-/// MediaType type = mediaParser(actionString);
-/// print(type);
-/// ```
-/// Output:
-/// ```bash
-/// MediaType.video
-/// ```
MediaType? mediaParser(String? mediaString) {
MediaType? type;
diff --git a/mobile/apps/photos/plugins/media_extension/lib/media_extension_method_channel.dart b/mobile/apps/photos/plugins/media_extension/lib/media_extension_method_channel.dart
index 0b819b1483..c4a8f4df16 100644
--- a/mobile/apps/photos/plugins/media_extension/lib/media_extension_method_channel.dart
+++ b/mobile/apps/photos/plugins/media_extension/lib/media_extension_method_channel.dart
@@ -5,9 +5,7 @@ import 'package:flutter/services.dart';
import 'package:media_extension/media_extension_action_types.dart';
import 'package:media_extension/media_extension_platform_interface.dart';
-/// An implementation of [MediaExtensionPlatform] that uses method channels.
class MethodChannelMediaExtension extends MediaExtensionPlatform {
- /// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('media_extension');
@@ -42,7 +40,6 @@ class MethodChannelMediaExtension extends MediaExtensionPlatform {
);
}
- /// This Method retrivies the platform version from native thread.
@override
Future<String?> getPlatformVersion() async {
final version = await methodChannel.invokeMethod<String>(
@@ -51,9 +48,6 @@ class MethodChannelMediaExtension extends MediaExtensionPlatform {
return version;
}
- /// This Method sends the selected Image's [uri] to the native thread.
- /// from the Flutter thread to send results to apps
- /// which can handle [ACTION_ATTACH_DATA] Intent of [mimeType] `images/*`.
@override
Future<bool> setAs(
String uri,
@@ -72,9 +66,6 @@ class MethodChannelMediaExtension extends MediaExtensionPlatform {
return false;
}
- /// This Method sends the selected Image's [uri] to the native thread.
- /// from the Flutter thread to send results to apps
- /// which can handle [ACTION_EDIT] Intent of [mimeType] `images/*`.
@override
Future<bool> edit(
String uri,
@@ -94,9 +85,6 @@ class MethodChannelMediaExtension extends MediaExtensionPlatform {
return false;
}
- /// This Method sends the selected Image's [uri] to the native thread.
- /// from the Flutter thread to send results
- /// to apps which can handle [ACTION_VIEW] Intent of [mimeType] `images/*`.
@override
Future<bool> openWith(
String uri,
@@ -115,8 +103,6 @@ class MethodChannelMediaExtension extends MediaExtensionPlatform {
return false;
}
- /// This Method is triggered by the Native Thread which sends the [intentAction]
- /// and [uri] information in a [HashMap] Structure to the Flutter thread.
@override
Future<MediaExtentionAction> getIntentAction() async {
_ensureMethodCallHandler();
@@ -141,9 +127,6 @@ class MethodChannelMediaExtension extends MediaExtensionPlatform {
return _intentActionController.stream;
}
- /// This Method sends the selected Image's [uri] to the native thread.
- /// from the Flutter thread to send results to the app
- /// which invoked our app using [ACTION_PICK] INTENT.
@override
Future<void> setResult(String uri) async {
try {
@@ -153,9 +136,6 @@ class MethodChannelMediaExtension extends MediaExtensionPlatform {
}
}
- /// This Method sends selected media [uris] to the native thread.
- /// from the Flutter thread to send results to the app
- /// which invoked our app using [ACTION_PICK] INTENT.
@override
Future<void> setResults(List<String> uris) async {
try {
@@ -165,8 +145,6 @@ class MethodChannelMediaExtension extends MediaExtensionPlatform {
}
}
- /// This Method cancels the result to the app
- /// which invoked our app using [ACTION_PICK] INTENT.
@override
Future<void> cancelResult() async {
try {
diff --git a/mobile/apps/photos/plugins/media_extension/lib/media_extension_platform_interface.dart b/mobile/apps/photos/plugins/media_extension/lib/media_extension_platform_interface.dart
index ebb6d90a9b..b760260ea1 100644
--- a/mobile/apps/photos/plugins/media_extension/lib/media_extension_platform_interface.dart
+++ b/mobile/apps/photos/plugins/media_extension/lib/media_extension_platform_interface.dart
@@ -5,32 +5,23 @@ import 'package:media_extension/media_extension_method_channel.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
abstract class MediaExtensionPlatform extends PlatformInterface {
- /// Constructs a MediaExtensionPlatform.
MediaExtensionPlatform() : super(token: _token);
static final Object _token = Object();
static MediaExtensionPlatform _instance = MethodChannelMediaExtension();
- /// The default instance of [MediaExtensionPlatform] to use.
- ///
- /// Defaults to [MethodChannelMediaExtension].
static MediaExtensionPlatform get instance => _instance;
- /// Platform-specific implementations should set this with their own
- /// platform-specific class that extends [MediaExtensionPlatform] when
- /// they register themselves.
static set instance(MediaExtensionPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
- /// abstract method for `getPlatformVersion` method.
Future<String?> getPlatformVersion() {
throw UnimplementedError('platformVersion() has not been implemented.');
}
- /// abstract method for `setAs` method.
Future<bool> setAs(
String uri,
String mimeType, {
@@ -39,7 +30,6 @@ abstract class MediaExtensionPlatform extends PlatformInterface {
throw UnimplementedError('platformVersion() has not been implemented.');
}
- /// abstract method for `edit` method.
Future<bool> edit(
String uri,
String mimeType, {
@@ -48,7 +38,6 @@ abstract class MediaExtensionPlatform extends PlatformInterface {
throw UnimplementedError('platformVersion() has not been implemented.');
}
- /// abstract method `openWith` method.
Future<bool> openWith(
String uri,
String mimeType, {
@@ -57,32 +46,26 @@ abstract class MediaExtensionPlatform extends PlatformInterface {
throw UnimplementedError('platformVersion() has not been implemented.');
}
- /// abstract method `getIntentAction` method.
Future<MediaExtentionAction> getIntentAction() async {
throw UnimplementedError('platformVersion() has not been implemented.');
}
- /// abstract method `readUriBytes` method.
Future<Uint8List?> readUriBytes(String uri) async {
throw UnimplementedError('readUriBytes() has not been implemented.');
}
- /// abstract stream for warm intent actions received after startup.
Stream<MediaExtentionAction> get intentActionStream {
throw UnimplementedError('intentActionStream has not been implemented.');
}
- /// abstract method `setResult` method.
Future<void> setResult(String uri) async {
throw UnimplementedError('platformVersion() has not been implemented.');
}
- /// abstract method `setResults` method.
Future<void> setResults(List<String> uris) async {
throw UnimplementedError('platformVersion() has not been implemented.');
}
- /// abstract method `cancelResult` method.
Future<void> cancelResult() async {
throw UnimplementedError('platformVersion() has not been implemented.');
}
diff --git a/mobile/cargokit/build_tool/lib/src/cargo.dart b/mobile/cargokit/build_tool/lib/src/cargo.dart
index f49b5aca34..b2a1697e7e 100644
--- a/mobile/cargokit/build_tool/lib/src/cargo.dart
+++ b/mobile/cargokit/build_tool/lib/src/cargo.dart
@@ -27,8 +27,6 @@ class CrateInfo {
final String packageName;
- /// Name of the default lib target, as derived by cargo from the package
- /// name (dashes replaced with underscores). Determines artifact file names.
String get libName => packageName.replaceAll('-', '_');
static CrateInfo parseManifest(String manifest, {final String? fileName}) {
diff --git a/mobile/cargokit/gradle/plugin.gradle b/mobile/cargokit/gradle/plugin.gradle
index 0acce94b70..bb82a81be5 100644
--- a/mobile/cargokit/gradle/plugin.gradle
+++ b/mobile/cargokit/gradle/plugin.gradle
@@ -1,5 +1,5 @@
-/// This is copied from Cargokit (which is the official way to use it currently)
-/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin
+// This is copied from Cargokit (which is the official way to use it currently)
+// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin
import java.nio.file.Paths
import org.apache.tools.ant.taskdefs.condition.Os
diff --git a/mobile/packages/ente_components/lib/components/buttons/fab_component.dart b/mobile/packages/ente_components/lib/components/buttons/fab_component.dart
index 3663298e29..c58d1f90bc 100644
--- a/mobile/packages/ente_components/lib/components/buttons/fab_component.dart
+++ b/mobile/packages/ente_components/lib/components/buttons/fab_component.dart
@@ -7,7 +7,7 @@ import "package:flutter/material.dart";
enum FABComponentVariant { primary, secondary, destructive }
-/// Figma: https://www.figma.com/design/BuBNPPytxlVnqfmCUW0mgz/Ente-Visual-Design?node-id=21843-6537&m=dev
+// Figma: https://www.figma.com/design/BuBNPPytxlVnqfmCUW0mgz/Ente-Visual-Design?node-id=21843-6537&m=dev
class FABComponent extends StatefulWidget {
final String? label;
diff --git a/rust/bindings/frb/locker/src/api/document_scanner_api.rs b/rust/bindings/frb/locker/src/api/document_scanner_api.rs
index 64b0bb18b4..e06b91f58d 100644
--- a/rust/bindings/frb/locker/src/api/document_scanner_api.rs
+++ b/rust/bindings/frb/locker/src/api/document_scanner_api.rs
@@ -37,9 +37,8 @@ pub struct RustPlaneLayout {
#[derive(Clone, Debug)]
pub struct RustReprocessOptions {
- /// Same space as `RustScanResult.quad`: the decoded source image.
+ // Same space as `RustScanResult.quad`: the decoded source image.
pub quad: RustQuad,
- /// Must be a multiple of 90.
pub rotation_degrees: i32,
pub color_mode: RustColorMode,
pub max_pixels: Option<u32>,
@@ -47,15 +46,13 @@ pub struct RustReprocessOptions {
#[derive(Clone, Debug)]
pub struct RustScanResult {
- /// Decoded-source coordinates (EXIF applied, before `rotation_degrees`); `None` when nothing was detected.
+ // Decoded-source coordinates (EXIF applied, before `rotation_degrees`); `None` when nothing was detected.
pub quad: Option<RustQuad>,
pub color_mode: RustColorMode,
pub output_width: u32,
pub output_height: u32,
- /// The size `quad` is relative to.
pub source_width: u32,
pub source_height: u32,
- /// JPEG-encoded.
pub processed_image: Vec<u8>,
}
@@ -80,7 +77,7 @@ impl ScannerSession {
})
}
- /// The returned quad is in mask space (256x256), already rotated by `rotation_degrees`.
+ // The returned quad is in mask space (256x256), already rotated by `rotation_degrees`.
pub fn live_detect_bgra(
&self,
bgra: Vec<u8>,
@@ -100,7 +97,6 @@ impl ScannerSession {
})
}
- /// Quad semantics as in [`Self::live_detect_bgra`].
pub fn live_detect_yuv420(
&self,
y: Vec<u8>,
diff --git a/rust/bindings/wasm/legacy/src/types.rs b/rust/bindings/wasm/legacy/src/types.rs
index 5b3021112f..33a1c8fb96 100644
--- a/rust/bindings/wasm/legacy/src/types.rs
+++ b/rust/bindings/wasm/legacy/src/types.rs
@@ -242,7 +242,7 @@ pub struct LegacyKitRecoverySession {
#[serde(rename = "kitID")]
kit_id: String,
status: LegacyKitRecoveryStatus,
- /// Remaining microseconds, not an epoch timestamp.
+ // Remaining microseconds, not an epoch timestamp.
wait_till: i64,
created_at: i64,
}
diff --git a/rust/crates/ml/src/cv/canny.rs b/rust/crates/ml/src/cv/canny.rs
index 15bf30efaf..4a4d81c30e 100644
--- a/rust/crates/ml/src/cv/canny.rs
+++ b/rust/crates/ml/src/cv/canny.rs
@@ -1,12 +1,12 @@
-//! The 75/200 thresholds used downstream are calibrated against this exact
-//! gradient scaling: integer `|dx| + |dy|` of a 3x3 Sobel with replicated
-//! borders, thresholds floored, the low one compared strictly.
+// The 75/200 thresholds used downstream are calibrated against this exact
+// gradient scaling: integer `|dx| + |dy|` of a 3x3 Sobel with replicated
+// borders, thresholds floored, the low one compared strictly.
use crate::cv::OpResult;
use crate::cv::image::ImageU8;
const CANNY_SHIFT: i32 = 15;
-/// `(int)(tan(22.5 deg) * (1 << CANNY_SHIFT) + 0.5)`.
+// `(int)(tan(22.5 deg) * (1 << CANNY_SHIFT) + 0.5)`.
const TG22: i32 = 13573;
const MAYBE: u8 = 0;
diff --git a/rust/crates/ml/src/cv/lab.rs b/rust/crates/ml/src/cv/lab.rs
index efa5ce7430..6a4141bf92 100644
--- a/rust/crates/ml/src/cv/lab.rs
+++ b/rust/crates/ml/src/cv/lab.rs
@@ -1,5 +1,5 @@
-//! L, a and b are all scaled onto 0..255 (a and b biased by 128); the
-//! pipeline's chroma and luminance thresholds are calibrated in these units.
+// L, a and b are all scaled onto 0..255 (a and b biased by 128); the
+// pipeline's chroma and luminance thresholds are calibrated in these units.
use std::sync::OnceLock;
diff --git a/rust/crates/ml/src/cv/resize.rs b/rust/crates/ml/src/cv/resize.rs
index 5c9c79d460..1c8c49b192 100644
--- a/rust/crates/ml/src/cv/resize.rs
+++ b/rust/crates/ml/src/cv/resize.rs
@@ -1,4 +1,4 @@
-//! Sampling without low-pass filtering; downstream calibration depends on that.
+// Sampling without low-pass filtering; downstream calibration depends on that.
use fast_image_resize::{
FilterType, PixelType, ResizeAlg, ResizeOptions, Resizer,
diff --git a/rust/crates/ml/src/onnx.rs b/rust/crates/ml/src/onnx.rs
index ac4e799bba..679040fd42 100644
--- a/rust/crates/ml/src/onnx.rs
+++ b/rust/crates/ml/src/onnx.rs
@@ -76,8 +76,8 @@ impl OnnxSession {
}
}
- /// Only for models whose output is not indexed and so cannot
- /// silently poison stored data.
+ // Only for models whose output is not indexed and so cannot
+ // silently poison stored data.
pub(crate) fn with_unvalidated_acceleration(mut self) -> Self {
self.validation = AccelerationValidation::Unvalidated;
self
diff --git a/rust/crates/ml/src/scan/detection.rs b/rust/crates/ml/src/scan/detection.rs
index b4af8520ab..0804ac8beb 100644
--- a/rust/crates/ml/src/scan/detection.rs
+++ b/rust/crates/ml/src/scan/detection.rs
@@ -74,7 +74,7 @@ fn find_quad_from_orientation_with_adaptive_threshold(
Ok(best_quad)
}
-/// Deliberately no upper bound: edge-touching documents put corners past the mask edge.
+// Deliberately no upper bound: edge-touching documents put corners past the mask edge.
pub(crate) fn is_valid_quad(quad: &[Point]) -> bool {
quad.iter().all(|p| p.x >= 0.0 && p.y >= 0.0)
}
diff --git a/rust/crates/ml/src/scan/yuv.rs b/rust/crates/ml/src/scan/yuv.rs
index 20cc642f49..745f11a114 100644
--- a/rust/crates/ml/src/scan/yuv.rs
+++ b/rust/crates/ml/src/scan/yuv.rs
@@ -1,7 +1,7 @@
-//! Reproduces libyuv's limited-range BT.601 fixed-point arithmetic β€” not the
-//! textbook full-range matrix β€” because that is what Android camera stacks
-//! apply when converting frames to RGBA, so YUV and RGBA frames yield the
-//! same quad.
+// Reproduces libyuv's limited-range BT.601 fixed-point arithmetic instead of
+// the textbook full-range matrix because that is what Android camera stacks
+// apply when converting frames to RGBA, so YUV and RGBA frames yield the
+// same quad.
use crate::cv;
use crate::cv::image::ImageU8;