diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d7181b6d..5cdae9b5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -82,7 +82,7 @@ jobs: run: | python -I -m pytest tests/ --cov-append --cov-report=xml --cov=menuinst -vvv - - uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a #v5.0.2 + - uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a #v5.0.7 with: name: ${{ matrix.os }}-py${{ matrix.python-version }} token: ${{ secrets.CODECOV_TOKEN }} # required diff --git a/docs/environment.yml b/docs/environment.yml index 5d5d6f4e..eb57724a 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -13,6 +13,7 @@ dependencies: - cffi=1.15.1 - charset-normalizer=2.1.1 - colorama=0.4.6 + - commonmark=0.9.1 - cryptography=38.0.3 - docutils=0.19 - idna=3.4 diff --git a/docs/source/conf.py b/docs/source/conf.py index c669677f..4148b3a4 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -6,8 +6,11 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html import json +import os from pathlib import Path +import commonmark + # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information @@ -117,3 +120,20 @@ sitemap_locales = [None] # We're hard-coding stable here since that's what we want Google to point to. sitemap_url_scheme = "{link}" + + +# Custom hooks +os.environ["SPHINX_RUNNING"] = "1" + + +def docstring(app, what, name, obj, options, lines): + """Transform MD to RST for autodoc""" + md = '\n'.join(lines) + ast = commonmark.Parser().parse(md) + rst = commonmark.ReStructuredTextRenderer().render(ast) + lines.clear() + lines += rst.splitlines() + + +def setup(app): + app.connect('autodoc-process-docstring', docstring) diff --git a/menuinst/_schema.py b/menuinst/_schema.py index 2f746ec3..1c15d135 100644 --- a/menuinst/_schema.py +++ b/menuinst/_schema.py @@ -3,8 +3,12 @@ """ # flake8: noqa +# pyright: reportInvalidTypeForm=false, reportCallIssue=false, reportGeneralTypeIssues=false import json +import os +import re +from inspect import cleandoc from logging import getLogger from pathlib import Path from pprint import pprint @@ -12,11 +16,13 @@ try: from pydantic.v1 import BaseModel as _BaseModel - from pydantic.v1 import Field, conlist, constr + from pydantic.v1 import Field as _Field + from pydantic.v1 import conlist, constr except ImportError: # pydantic v1 from pydantic import BaseModel as _BaseModel - from pydantic import Field, conlist, constr + from pydantic import Field as _Field + from pydantic import conlist, constr log = getLogger(__name__) @@ -25,10 +31,35 @@ SCHEMA_URL = f"https://schemas.conda.org/menuinst-{SCHEMA_VERSION}.schema.json" +def _clean_description(description: str) -> str: + # The regex below only replaces newlines surrounded by non-newlines + description = re.sub(r'(?``. - - See `AppUserModelID docs - `__ - for more information on the required string format. - """ + desktop: Optional[bool] = Field( + True, + description=("Whether to create a desktop icon in addition to the Start Menu item."), + ) + quicklaunch: Optional[bool] = Field( + False, + description=( + """ + DEPRECATED. Whether to create a quick launch icon in addition to the Start Menu item. + """ + ), + deprecated=True, + ) + terminal_profile: constr(min_length=1) = Field( + None, + description=( + """ + Name of the Windows Terminal profile to create. + This name must be unique across multiple installations because + menuinst will overwrite Terminal profiles with the same name. + """ + ), + ) + url_protocols: Optional[List[constr(regex=r"\S+")]] = Field( + None, + description=("URL protocols that will be associated with this program."), + ) + file_extensions: Optional[List[constr(regex=r"\.\S*")]] = Field( + None, + description=("File extensions that will be associated with this program."), + ) + app_user_model_id: Optional[constr(regex=r"\S+\.\S+", max_length=128)] = Field( + None, + description=( + """ + Identifier used in Windows 7 and above to associate processes, files and windows with a + particular application. If your shortcut produces duplicated icons, you need to define + this field. If not set, it will default to `Menuinst.`. + + See [AppUserModelID docs]( + https://learn.microsoft.com/en-us/windows/win32/shell/appids#how-to-form-an-application-defined-appusermodelid) + for more information on the required string format. + """ + ), + ) class Linux(BasePlatformSpecific): """ Linux-specific instructions. - Check the `Desktop entry specification - `__ + Check the [Desktop entry specification]( + https://specifications.freedesktop.org/desktop-entry-spec/latest/recognized-keys.html) for more details. """ - Categories: Optional[Union[List[str], constr(regex=r"^.+;$")]] = None - """ - Categories in which the entry should be shown in a menu. - "See 'Registered categories' in the `Menu Spec - `__. - """ - DBusActivatable: Optional[bool] = None - "A boolean value specifying if D-Bus activation is supported for this application." - GenericName: Optional[str] = None - """ - Generic name of the application; e.g. if the name is 'conda', - this would be 'Package Manager'. - """ - Hidden: Optional[bool] = None - "Disable shortcut, signaling a missing resource." - Implements: Optional[Union[List[str], constr(regex=r"^.+;$")]] = None - """ - List of supported interfaces. See 'Interfaces' in `Desktop Entry Spec - `__. - """ - Keywords: Optional[Union[List[str], constr(regex=r"^.+;$")]] = None - "Additional terms to describe this shortcut to aid in searching." - MimeType: Optional[Union[List[str], constr(regex=r"^.+;$")]] = None - """ - The MIME type(s) supported by this application. - Note this includes file types and URL protocols. - For URL protocols, use ``x-scheme-handler/your-protocol-here``. - For example, if you want to register ``menuinst:``, you would - include ``x-scheme-handler/menuinst``. - """ - NoDisplay: Optional[bool] = None - """ - Do not show this item in the menu. Useful to associate MIME types - and other registrations, without having an actual clickable item. - Not to be confused with 'Hidden'. - """ - NotShowIn: Optional[Union[List[str], constr(regex=r"^.+;$")]] = None - """ - Desktop environments that should NOT display this item. - It'll check against ``$XDG_CURRENT_DESKTOP``." - """ - OnlyShowIn: Optional[Union[List[str], constr(regex=r"^.+;$")]] = None - """ - Desktop environments that should display this item. - It'll check against ``$XDG_CURRENT_DESKTOP``. - """ - PrefersNonDefaultGPU: Optional[bool] = None - "Hint that the app prefers to be run on a more powerful discrete GPU if available." - SingleMainWindow: Optional[bool] = None - """ - Do not show the 'New Window' option in the app's context menu. - """ - StartupNotify: Optional[bool] = None - """ - Advanced. See `Startup Notification spec - `__. - """ - StartupWMClass: Optional[str] = None - """ - Advanced. See `Startup Notification spec - `__. - """ - TryExec: Optional[str] = None - """ - Filename or absolute path to an executable file on disk used to - determine if the program is actually installed and can be run. If the test - fails, the shortcut might be ignored / hidden. - """ - glob_patterns: Optional[Dict[str, constr(regex=r".*\*.*")]] = None - """ - Map of custom MIME types to their corresponding glob patterns (e.g. ``*.txt``). - Only needed if you define custom MIME types in ``MimeType``. - """ + Categories: Optional[Union[List[str], constr(regex=r"^.+;$")]] = Field( + None, + description=( + """ + Categories in which the entry should be shown in a menu. + See 'Registered categories' in the [Menu Spec]( + http://www.freedesktop.org/Standards/menu-spec). + """ + ), + ) + DBusActivatable: Optional[bool] = Field( + None, + description=( + """ + A boolean value specifying if D-Bus activation is supported for this application. + """ + ), + ) + GenericName: Optional[str] = Field( + None, + description=( + """ + Generic name of the application; e.g. if the name is 'conda', + this would be 'Package Manager'. + """ + ), + ) + Hidden: Optional[bool] = Field( + None, + description=("Disable shortcut, signaling a missing resource."), + ) + Implements: Optional[Union[List[str], constr(regex=r"^.+;$")]] = Field( + None, + description=( + """ + List of supported interfaces. See 'Interfaces' in [Desktop Entry Spec]( + https://specifications.freedesktop.org/desktop-entry-spec/latest/interfaces.html). + """ + ), + ) + Keywords: Optional[Union[List[str], constr(regex=r"^.+;$")]] = Field( + None, + description=("Additional terms to describe this shortcut to aid in searching."), + ) + MimeType: Optional[Union[List[str], constr(regex=r"^.+;$")]] = Field( + None, + description=( + """ + The MIME type(s) supported by this application. + Note this includes file types and URL protocols. + For URL protocols, use `x-scheme-handler/your-protocol-here`. + For example, if you want to register `menuinst:`, you would + include `x-scheme-handler/menuinst`. + """ + ), + ) + NoDisplay: Optional[bool] = Field( + None, + description=( + """ + Do not show this item in the menu. Useful to associate MIME types + and other registrations, without having an actual clickable item. + Not to be confused with 'Hidden'. + """ + ), + ) + NotShowIn: Optional[Union[List[str], constr(regex=r"^.+;$")]] = Field( + None, + description=( + """ + Desktop environments that should NOT display this item. + It'll check against `$XDG_CURRENT_DESKTOP`. + """ + ), + ) + OnlyShowIn: Optional[Union[List[str], constr(regex=r"^.+;$")]] = Field( + None, + description=( + """ + Desktop environments that should display this item. + It'll check against `$XDG_CURRENT_DESKTOP`. + """ + ), + ) + PrefersNonDefaultGPU: Optional[bool] = Field( + None, + description=( + """ + Hint that the app prefers to be run on a more powerful discrete GPU if available. + """ + ), + ) + SingleMainWindow: Optional[bool] = Field( + None, + description=( + """ + Do not show the 'New Window' option in the app's context menu. + """ + ), + ) + StartupNotify: Optional[bool] = Field( + None, + description=( + """ + Advanced. See [Startup Notification spec]( + https://www.freedesktop.org/wiki/Specifications/startup-notification-spec/). + """ + ), + ) + StartupWMClass: Optional[str] = Field( + None, + description=( + """ + Advanced. See [Startup Notification spec]( + https://www.freedesktop.org/wiki/Specifications/startup-notification-spec/). + """ + ), + ) + TryExec: Optional[str] = Field( + None, + description=( + """ + Filename or absolute path to an executable file on disk used to + determine if the program is actually installed and can be run. If the test + fails, the shortcut might be ignored / hidden. + """ + ), + ) + glob_patterns: Optional[Dict[str, constr(regex=r".*\*.*")]] = Field( + None, + description=( + """ + Map of custom MIME types to their corresponding glob patterns (e.g. `*.txt`). + Only needed if you define custom MIME types in `MimeType`. + """ + ), + ) class MacOS(BasePlatformSpecific): """ Mac-specific instructions. Check these URLs for more info: - - ``CF*`` keys: see `Core Foundation Keys `__ - - ``LS*`` keys: see `Launch Services Keys `__ - - ``entitlements``: see `Entitlements documentation `__ + - `CF*` keys: see [Core Foundation Keys](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html) + - `LS*` keys: see [Launch Services Keys](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html) + - `entitlements`: see [Entitlements documentation](https://developer.apple.com/documentation/bundleresources/entitlements) """ class CFBundleURLTypesModel(BaseModel): "Describes a URL scheme associated with the app." - CFBundleTypeRole: Optional[Literal["Editor", "Viewer", "Shell", "None"]] = None - "This key specifies the app's role with respect to the URL." - CFBundleURLSchemes: List[str] = ... - "URL schemes / protocols handled by this type (e.g. 'mailto').", - CFBundleURLName: Optional[str] = None - "Abstract name for this URL type. Uniqueness recommended.", - CFBundleURLIconFile: Optional[str] = None - "Name of the icon image file (minus the .icns extension).", + + CFBundleTypeRole: Optional[Literal["Editor", "Viewer", "Shell", "None"]] = Field( + None, + description=("This key specifies the app's role with respect to the URL."), + ) + CFBundleURLSchemes: List[str] = Field( + ..., + description=("URL schemes / protocols handled by this type (e.g. 'mailto')."), + ) + CFBundleURLName: Optional[str] = Field( + None, + description=("Abstract name for this URL type. Uniqueness recommended."), + ) + CFBundleURLIconFile: Optional[str] = Field( + None, + description=("Name of the icon image file (minus the .icns extension)."), + ) class CFBundleDocumentTypesModel(BaseModel): "Describes a document type associated with the app." - CFBundleTypeIconFile: Optional[str] = None - "Name of the icon image file (minus the .icns extension).", - CFBundleTypeName: str = ... - "Abstract name for this document type. Uniqueness recommended.", - CFBundleTypeRole: Optional[Literal["Editor", "Viewer", "Shell", "None"]] = None - "This key specifies the app's role with respect to the type." - LSItemContentTypes: List[str] = ... - """ - List of UTI strings defining a supported file type; e.g. for - PNG files, use 'public.png'. See `UTI Reference - `__ - for more info about the system-defined UTIs. Custom UTIs can be - defined via 'UTExportedTypeDeclarations'. UTIs defined by other - apps (not the system) need to be imported via 'UTImportedTypeDeclarations'. - - See `Fun with UTIs `__ for more info. - """ - LSHandlerRank: Literal["Owner", "Default", "Alternate"] = ... - """ - Determines how Launch Services ranks this app among the apps - that declare themselves editors or viewers of files of this type. - """ + + CFBundleTypeIconFile: Optional[str] = Field( + None, + description=("Name of the icon image file (minus the .icns extension)."), + ) + CFBundleTypeName: str = Field( + ..., + description=("Abstract name for this document type. Uniqueness recommended."), + ) + CFBundleTypeRole: Optional[Literal["Editor", "Viewer", "Shell", "None"]] = Field( + None, description=("This key specifies the app's role with respect to the type.") + ) + LSItemContentTypes: List[str] = Field( + ..., + description=( + """ + List of UTI strings defining a supported file type; e.g. for PNG files, use + 'public.png'. See [UTI Reference]( + https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html) + for more info about the system-defined UTIs. Custom UTIs can be defined via + 'UTExportedTypeDeclarations'. UTIs defined by other apps (not the system) need to + be imported via 'UTImportedTypeDeclarations'. + + See [Fun with UTIs](https://www.cocoanetics.com/2012/09/fun-with-uti/) for more + info. + """ + ), + ) + LSHandlerRank: Literal["Owner", "Default", "Alternate"] = Field( + ..., + description=( + """ + Determines how Launch Services ranks this app among the apps + that declare themselves editors or viewers of files of this type. + """ + ), + ) class UTTypeDeclarationModel(BaseModel): - UTTypeConformsTo: List[str] = ... - "The Uniform Type Identifier types that this type conforms to." - UTTypeDescription: Optional[str] = None - "A description for this type." - UTTypeIconFile: Optional[str] = None - "The bundle icon resource to associate with this type." - UTTypeIdentifier: str = ... - "The Uniform Type Identifier to assign to this type." - UTTypeReferenceURL: Optional[str] = None - "The webpage for a reference document that describes this type." - UTTypeTagSpecification: Dict[str, List[str]] = ... - "A dictionary defining one or more equivalent type identifiers." - - CFBundleDisplayName: Optional[str] = None - """ - Display name of the bundle, visible to users and used by Siri. If - not provided, 'menuinst' will use the 'name' field. - """ - CFBundleIdentifier: Optional[constr(regex=r"^[A-z0-9\-\.]+$")] = None - """ - Unique identifier for the shortcut. Typically uses a reverse-DNS format. - If not provided, 'menuinst' will generate one from the 'name' field. - """ - CFBundleName: Optional[constr(max_length=16)] = None - """ - Short name of the bundle. May be used if ``CFBundleDisplayName`` is - absent. If not provided, 'menuinst' will generate one from the 'name' field. - """ - CFBundleSpokenName: Optional[str] = None - """ - Suitable replacement for text-to-speech operations on the app. - For example, 'my app one two three' instead of 'MyApp123'. - """ - CFBundleVersion: Optional[constr(regex=r"^\S+$")] = None - """ - Build version number for the bundle. In the context of 'menuinst' - this can be used to signal a new version of the menu item for the same - application version. - """ - CFBundleURLTypes: Optional[List[CFBundleURLTypesModel]] = None - """ - URL types supported by this app. Requires setting `event_handler` too. - Note this feature requires macOS 10.14.4 or above. - """ - CFBundleDocumentTypes: Optional[List[CFBundleDocumentTypesModel]] = None - """ - Document types supported by this app. Requires setting `event_handler` too. - Requires macOS 10.14.4 or above. - """ - LSApplicationCategoryType: Optional[constr(regex=r"^public\.app-category\.\S+$")] = None - "The App Store uses this string to determine the appropriate categorization." - LSBackgroundOnly: Optional[bool] = None - "Specifies whether this app runs only in the background." - LSEnvironment: Optional[Dict[str, str]] = None - "List of key-value pairs used to define environment variables.", - LSMinimumSystemVersion: Optional[constr(regex=r"^\d+\.\d+\.\d+$")] = None - """ - Minimum version of macOS required for this app to run, as ``x.y.z``. - For example, for macOS v10.4 and later, use ``10.4.0``. - """ - LSMultipleInstancesProhibited: Optional[bool] = None - "Whether an app is prohibited from running simultaneously in multiple user sessions." - LSRequiresNativeExecution: Optional[bool] = None - """ - If true, prevent a universal binary from being run under - Rosetta emulation on an Intel-based Mac. - """ - NSSupportsAutomaticGraphicsSwitching: Optional[bool] = None - """If true, allows an OpenGL app to utilize the integrated GPU.""" - UTExportedTypeDeclarations: Optional[List[UTTypeDeclarationModel]] = None - "The uniform type identifiers owned and exported by the app." - UTImportedTypeDeclarations: Optional[List[UTTypeDeclarationModel]] = None - "The uniform type identifiers inherently supported, but not owned, by the app." - entitlements: Optional[List[constr(regex=r"[a-z0-9\.\-]+")]] = None - """ - List of permissions to request for the launched application. - See `the entitlements docs `__ - for a full list of possible values. - """ + UTTypeConformsTo: List[str] = Field( + ..., + description=("The Uniform Type Identifier types that this type conforms to."), + ) + UTTypeDescription: Optional[str] = Field( + None, + description=("A description for this type."), + ) + UTTypeIconFile: Optional[str] = Field( + None, + description=("The bundle icon resource to associate with this type."), + ) + UTTypeIdentifier: str = Field( + ..., + description=("The Uniform Type Identifier to assign to this type."), + ) + UTTypeReferenceURL: Optional[str] = Field( + None, + description=("The webpage for a reference document that describes this type."), + ) + UTTypeTagSpecification: Dict[str, List[str]] = Field( + ..., + description=("A dictionary defining one or more equivalent type identifiers."), + ) + + CFBundleDisplayName: Optional[str] = Field( + None, + description=( + """ + Display name of the bundle, visible to users and used by Siri. If + not provided, 'menuinst' will use the 'name' field. + """ + ), + ) + CFBundleIdentifier: Optional[constr(regex=r"^[A-z0-9\-\.]+$")] = Field( + None, + description=( + """ + Unique identifier for the shortcut. Typically uses a reverse-DNS format. + If not provided, 'menuinst' will generate one from the 'name' field. + """ + ), + ) + CFBundleName: Optional[constr(max_length=16)] = Field( + None, + description=( + """ + Short name of the bundle. May be used if `CFBundleDisplayName` is + absent. If not provided, 'menuinst' will generate one from the 'name' field. + """ + ), + ) + CFBundleSpokenName: Optional[str] = Field( + None, + description=( + """ + Suitable replacement for text-to-speech operations on the app. + For example, 'my app one two three' instead of 'MyApp123'. + """ + ), + ) + CFBundleVersion: Optional[constr(regex=r"^\S+$")] = Field( + None, + description=( + """ + Build version number for the bundle. In the context of 'menuinst' + this can be used to signal a new version of the menu item for the same + application version. + """ + ), + ) + CFBundleURLTypes: Optional[List[CFBundleURLTypesModel]] = Field( + None, + description=( + """ + URL types supported by this app. Requires setting `event_handler` too. + Note this feature requires macOS 10.14.4 or above. + """ + ), + ) + CFBundleDocumentTypes: Optional[List[CFBundleDocumentTypesModel]] = Field( + None, + description=( + """ + Document types supported by this app. Requires setting `event_handler` too. + Requires macOS 10.14.4 or above. + """ + ), + ) + LSApplicationCategoryType: Optional[constr(regex=r"^public\.app-category\.\S+$")] = Field( + None, + description=( + "The App Store uses this string to determine the appropriate categorization." + ), + ) + LSBackgroundOnly: Optional[bool] = Field( + None, + description=("Specifies whether this app runs only in the background."), + ) + LSEnvironment: Optional[Dict[str, str]] = Field( + None, + description=("List of key-value pairs used to define environment variables."), + ) + LSMinimumSystemVersion: Optional[constr(regex=r"^\d+\.\d+\.\d+$")] = Field( + None, + description=( + """ + Minimum version of macOS required for this app to run, as `x.y.z`. + For example, for macOS v10.4 and later, use `10.4.0`. + """ + ), + ) + LSMultipleInstancesProhibited: Optional[bool] = Field( + None, + description=( + """ + Whether an app is prohibited from running simultaneously in multiple user sessions. + """ + ), + ) + LSRequiresNativeExecution: Optional[bool] = Field( + None, + description=( + """ + If true, prevent a universal binary from being run under + Rosetta emulation on an Intel-based Mac. + """ + ), + ) + NSSupportsAutomaticGraphicsSwitching: Optional[bool] = Field( + None, + description=("If true, allows an OpenGL app to utilize the integrated GPU."), + ) + UTExportedTypeDeclarations: Optional[List[UTTypeDeclarationModel]] = Field( + None, + description=("The uniform type identifiers owned and exported by the app."), + ) + UTImportedTypeDeclarations: Optional[List[UTTypeDeclarationModel]] = Field( + None, + description=( + "The uniform type identifiers inherently supported, but not owned, by the app." + ), + ) + entitlements: Optional[List[constr(regex=r"[a-z0-9\.\-]+")]] = Field( + None, + description=( + """ + List of permissions to request for the launched application. See [the entitlements docs]( + https://developer.apple.com/documentation/bundleresources/entitlements) for a full + list of possible values. + """ + ), + ) link_in_bundle: Optional[Dict[constr(min_length=1), constr(regex=r"^(?!\/)(?!\.\./).*")]] = ( - None + Field( + None, + description=( + """ + Paths that should be symlinked into the shortcut app bundle. + It takes a mapping of source to destination paths. Destination paths must be + relative. Placeholder `{{ MENU_ITEM_LOCATION }}` can be useful. + """ + ), + ) + ) + event_handler: Optional[constr(min_length=1)] = Field( + None, + description=( + """ + Required shell script logic to handle opened URL payloads. + Note this feature requires macOS 10.14.4 or above. + """ + ), ) - """ - Paths that should be symlinked into the shortcut app bundle. - It takes a mapping of source to destination paths. Destination paths must be - relative. Placeholder ``{{ MENU_ITEM_LOCATION }}`` can be useful. - """ - event_handler: Optional[constr(min_length=1)] = None - """ - Required shell script logic to handle opened URL payloads. - Note this feature requires macOS 10.14.4 or above. - """ class Platforms(BaseModel): """ Platform specific options. - Note each of these fields supports the same keys as the top-level :class:`MenuItem` - (sans ``platforms`` itself), in case overrides are needed. + Note each of these fields supports the same keys as the top-level `MenuItem` + (sans `platforms` itself), in case overrides are needed. """ - linux: Optional[Linux] - "Options for Linux. See :class:`Linux` model for details." - osx: Optional[MacOS] - "Options for macOS. See :class:`MacOS` model for details." - win: Optional[Windows] - "Options for Windows. See :class:`Windows` model for details." + linux: Optional[Linux] = Field( + description=("Options for Linux. See `Linux` model for details."), + ) + osx: Optional[MacOS] = Field( + description=("Options for macOS. See `MacOS` model for details."), + ) + win: Optional[Windows] = Field( + description=("Options for Windows. See `Windows` model for details."), + ) class MenuItem(BaseModel): "Instructions to create a menu item across operating systems." - name: Union[constr(min_length=1), MenuItemNameDict] = ... - """ - The name of the menu item. Can be a dictionary if the name depends on - installation parameters. See :class:`MenuItemNameDict` for details. - """ - description: str = ... - "A longer description of the menu item. Shown on popup messages." - command: conlist(str, min_items=1) = ... - """ - Command to run with the menu item, expressed as a - list of strings where each string is an argument. - """ - icon: Optional[constr(min_length=1)] = None - "Path to the file representing or containing the icon." - precommand: Optional[constr(min_length=1)] = None - """ - (Simple, preferrably single-line) logic to run before the command is run. - Runs before the environment is activated, if that applies. - """ - precreate: Optional[constr(min_length=1)] = None - "(Simple, preferrably single-line) logic to run before the shortcut is created." - working_dir: Optional[constr(min_length=1)] = None - """ - Working directory for the running process. - Defaults to user directory on each platform. - """ - activate: Optional[bool] = True - "Whether to activate the target environment before running ``command``." - terminal: Optional[bool] = False - """ - Whether run the program in a terminal/console or not. - On Windows, it only has an effect if ``activate`` is true. - On MacOS, the application will ignore command-line arguments. - """ - platforms: Platforms - "Platform-specific options. Presence of a platform field enables menu items in that platform." + name: Union[constr(min_length=1), MenuItemNameDict] = Field( + ..., + description=( + """ + The name of the menu item. Can be a dictionary if the name depends on + installation parameters. See `MenuItemNameDict` for details. + """ + ), + ) + description: str = Field( + ..., + description=("A longer description of the menu item. Shown on popup messages."), + ) + command: conlist(str, min_items=1) = Field( + ..., + description=( + """ + Command to run with the menu item, expressed as a + list of strings where each string is an argument. + """ + ), + ) + icon: Optional[constr(min_length=1)] = Field( + None, + description=("Path to the file representing or containing the icon."), + ) + precommand: Optional[constr(min_length=1)] = Field( + None, + description=( + """ + (Simple, preferrably single-line) logic to run before the command is run. + Runs before the environment is activated, if that applies. + """ + ), + ) + precreate: Optional[constr(min_length=1)] = Field( + None, + description=( + """ + (Simple, preferrably single-line) logic to run before the shortcut is created. + """ + ), + ) + working_dir: Optional[constr(min_length=1)] = Field( + None, + description=( + """ + Working directory for the running process. + Defaults to user directory on each platform. + """ + ), + ) + activate: Optional[bool] = Field( + True, + description=("Whether to activate the target environment before running `command`."), + ) + terminal: Optional[bool] = Field( + False, + description=( + """ + Whether run the program in a terminal/console or not. + On Windows, it only has an effect if `activate` is true. + On MacOS, the application will ignore command-line arguments. + """ + ), + ) + platforms: Platforms = Field( + description=( + """ + Platform-specific options. Presence of a platform field enables + menu items in that platform. + """ + ), + ) class MenuInstSchema(BaseModel): - "Metadata required to create menu items across operating systems with ``menuinst``." + "Metadata required to create menu items across operating systems with `menuinst`." class Config(BaseModel.Config): schema_extra = { @@ -418,10 +715,14 @@ class Config(BaseModel.Config): description="Version of the menuinst schema.", alias="$schema", ) - menu_name: constr(min_length=1) = ... - "Name for the category containing the items specified in ``menu_items``." - menu_items: conlist(MenuItem, min_items=1) = ... - "List of menu entries to create across main desktop systems." + menu_name: constr(min_length=1) = Field( + ..., + description=("Name for the category containing the items specified in `menu_items`."), + ) + menu_items: conlist(MenuItem, min_items=1) = Field( + ..., + description=("List of menu entries to create across main desktop systems."), + ) def dump_schema_to_json(write=True): diff --git a/menuinst/data/menuinst.schema.json b/menuinst/data/menuinst.schema.json index 9aaa3a70..8491ce9f 100644 --- a/menuinst/data/menuinst.schema.json +++ b/menuinst/data/menuinst.schema.json @@ -1,11 +1,12 @@ { "title": "MenuInstSchema", - "description": "Metadata required to create menu items across operating systems with ``menuinst``.", + "description": "Metadata required to create menu items across operating systems with `menuinst`.", "type": "object", "properties": { "$id": { "title": "$Id", "description": "Version of the menuinst schema.", + "markdownDescription": "Version of the menuinst schema.", "enum": [ "https://schemas.conda.io/menuinst-1.schema.json" ], @@ -14,6 +15,7 @@ "$schema": { "title": "$Schema", "description": "Standard of the JSON schema we adhere to.", + "markdownDescription": "Standard of the JSON schema we adhere to.", "enum": [ "https://json-schema.org/draft-07/schema" ], @@ -21,11 +23,15 @@ }, "menu_name": { "title": "Menu Name", + "description": "Name for the category containing the items specified in `menu_items`.", + "markdownDescription": "Name for the category containing the items specified in `menu_items`.", "minLength": 1, "type": "string" }, "menu_items": { "title": "Menu Items", + "description": "List of menu entries to create across main desktop systems.", + "markdownDescription": "List of menu entries to create across main desktop systems.", "minItems": 1, "type": "array", "items": { @@ -40,32 +46,40 @@ "menu_items" ], "additionalProperties": false, + "markdownDescription": "Metadata required to create menu items across operating systems with `menuinst`.", "definitions": { "MenuItemNameDict": { "title": "MenuItemNameDict", - "description": "Variable menu item name.\nUse this dictionary if the menu item name depends on installation parameters\nsuch as the target environment.", + "description": "Variable menu item name. Use this dictionary if the menu item name depends on installation parameters such as the target environment.", "type": "object", "properties": { "target_environment_is_base": { "title": "Target Environment Is Base", + "description": "Name when target environment is the base environment.", + "markdownDescription": "Name when target environment is the base environment.", "minLength": 1, "type": "string" }, "target_environment_is_not_base": { "title": "Target Environment Is Not Base", + "description": "Name when target environment is not the base environment.", + "markdownDescription": "Name when target environment is not the base environment.", "minLength": 1, "type": "string" } }, - "additionalProperties": false + "additionalProperties": false, + "markdownDescription": "Variable menu item name. Use this dictionary if the menu item name depends on installation parameters such as the target environment." }, "Linux": { "title": "Linux", - "description": "Linux-specific instructions.\n\nCheck the `Desktop entry specification\n`__\nfor more details.", + "description": "Linux-specific instructions.\n\nCheck the [Desktop entry specification]( https://specifications.freedesktop.org/desktop-entry-spec/latest/recognized-keys.html) for more details.", "type": "object", "properties": { "name": { "title": "Name", + "description": "The name of the menu item. Can be a dictionary if the name depends on installation parameters. See `MenuItemNameDict` for details.", + "markdownDescription": "The name of the menu item. Can be a dictionary if the name depends on installation parameters. See `MenuItemNameDict` for details.", "anyOf": [ { "type": "string", @@ -78,15 +92,21 @@ }, "description": { "title": "Description", + "description": "A longer description of the menu item. Shown on popup messages.", + "markdownDescription": "A longer description of the menu item. Shown on popup messages.", "type": "string" }, "icon": { "title": "Icon", + "description": "Path to the file representing or containing the icon.", + "markdownDescription": "Path to the file representing or containing the icon.", "minLength": 1, "type": "string" }, "command": { "title": "Command", + "description": "Command to run with the menu item, expressed as a list of strings where each string is an argument.", + "markdownDescription": "Command to run with the menu item, expressed as a list of strings where each string is an argument.", "minItems": 1, "type": "array", "items": { @@ -95,29 +115,41 @@ }, "working_dir": { "title": "Working Dir", + "description": "Working directory for the running process. Defaults to user directory on each platform.", + "markdownDescription": "Working directory for the running process. Defaults to user directory on each platform.", "minLength": 1, "type": "string" }, "precommand": { "title": "Precommand", + "description": "(Simple, preferrably single-line) logic to run before the command is run. Runs before the environment is activated, if that applies.", + "markdownDescription": "(Simple, preferrably single-line) logic to run before the command is run. Runs before the environment is activated, if that applies.", "minLength": 1, "type": "string" }, "precreate": { "title": "Precreate", + "description": "(Simple, preferrably single-line) logic to run before the shortcut is created.", + "markdownDescription": "(Simple, preferrably single-line) logic to run before the shortcut is created.", "minLength": 1, "type": "string" }, "activate": { "title": "Activate", + "description": "Whether to activate the target environment before running `command`.", + "markdownDescription": "Whether to activate the target environment before running `command`.", "type": "boolean" }, "terminal": { "title": "Terminal", + "description": "Whether run the program in a terminal/console or not. On Windows, it only has an effect if `activate` is true. On MacOS, the application will ignore command-line arguments.", + "markdownDescription": "Whether run the program in a terminal/console or not. On Windows, it only has an effect if `activate` is true. On MacOS, the application will ignore command-line arguments.", "type": "boolean" }, "Categories": { "title": "Categories", + "description": "Categories in which the entry should be shown in a menu. See 'Registered categories' in the [Menu Spec]( http://www.freedesktop.org/Standards/menu-spec).", + "markdownDescription": "Categories in which the entry should be shown in a menu. See 'Registered categories' in the [Menu Spec]( http://www.freedesktop.org/Standards/menu-spec).", "anyOf": [ { "type": "array", @@ -133,18 +165,26 @@ }, "DBusActivatable": { "title": "Dbusactivatable", + "description": "A boolean value specifying if D-Bus activation is supported for this application.", + "markdownDescription": "A boolean value specifying if D-Bus activation is supported for this application.", "type": "boolean" }, "GenericName": { "title": "Genericname", + "description": "Generic name of the application; e.g. if the name is 'conda', this would be 'Package Manager'.", + "markdownDescription": "Generic name of the application; e.g. if the name is 'conda', this would be 'Package Manager'.", "type": "string" }, "Hidden": { "title": "Hidden", + "description": "Disable shortcut, signaling a missing resource.", + "markdownDescription": "Disable shortcut, signaling a missing resource.", "type": "boolean" }, "Implements": { "title": "Implements", + "description": "List of supported interfaces. See 'Interfaces' in [Desktop Entry Spec]( https://specifications.freedesktop.org/desktop-entry-spec/latest/interfaces.html).", + "markdownDescription": "List of supported interfaces. See 'Interfaces' in [Desktop Entry Spec]( https://specifications.freedesktop.org/desktop-entry-spec/latest/interfaces.html).", "anyOf": [ { "type": "array", @@ -160,6 +200,8 @@ }, "Keywords": { "title": "Keywords", + "description": "Additional terms to describe this shortcut to aid in searching.", + "markdownDescription": "Additional terms to describe this shortcut to aid in searching.", "anyOf": [ { "type": "array", @@ -175,6 +217,8 @@ }, "MimeType": { "title": "Mimetype", + "description": "The MIME type(s) supported by this application. Note this includes file types and URL protocols. For URL protocols, use `x-scheme-handler/your-protocol-here`. For example, if you want to register `menuinst:`, you would include `x-scheme-handler/menuinst`.", + "markdownDescription": "The MIME type(s) supported by this application. Note this includes file types and URL protocols. For URL protocols, use `x-scheme-handler/your-protocol-here`. For example, if you want to register `menuinst:`, you would include `x-scheme-handler/menuinst`.", "anyOf": [ { "type": "array", @@ -190,10 +234,14 @@ }, "NoDisplay": { "title": "Nodisplay", + "description": "Do not show this item in the menu. Useful to associate MIME types and other registrations, without having an actual clickable item. Not to be confused with 'Hidden'.", + "markdownDescription": "Do not show this item in the menu. Useful to associate MIME types and other registrations, without having an actual clickable item. Not to be confused with 'Hidden'.", "type": "boolean" }, "NotShowIn": { "title": "Notshowin", + "description": "Desktop environments that should NOT display this item. It'll check against `$XDG_CURRENT_DESKTOP`.", + "markdownDescription": "Desktop environments that should NOT display this item. It'll check against `$XDG_CURRENT_DESKTOP`.", "anyOf": [ { "type": "array", @@ -209,6 +257,8 @@ }, "OnlyShowIn": { "title": "Onlyshowin", + "description": "Desktop environments that should display this item. It'll check against `$XDG_CURRENT_DESKTOP`.", + "markdownDescription": "Desktop environments that should display this item. It'll check against `$XDG_CURRENT_DESKTOP`.", "anyOf": [ { "type": "array", @@ -224,26 +274,38 @@ }, "PrefersNonDefaultGPU": { "title": "Prefersnondefaultgpu", + "description": "Hint that the app prefers to be run on a more powerful discrete GPU if available.", + "markdownDescription": "Hint that the app prefers to be run on a more powerful discrete GPU if available.", "type": "boolean" }, "SingleMainWindow": { "title": "Singlemainwindow", + "description": "Do not show the 'New Window' option in the app's context menu.", + "markdownDescription": "Do not show the 'New Window' option in the app's context menu.", "type": "boolean" }, "StartupNotify": { "title": "Startupnotify", + "description": "Advanced. See [Startup Notification spec]( https://www.freedesktop.org/wiki/Specifications/startup-notification-spec/).", + "markdownDescription": "Advanced. See [Startup Notification spec]( https://www.freedesktop.org/wiki/Specifications/startup-notification-spec/).", "type": "boolean" }, "StartupWMClass": { "title": "Startupwmclass", + "description": "Advanced. See [Startup Notification spec]( https://www.freedesktop.org/wiki/Specifications/startup-notification-spec/).", + "markdownDescription": "Advanced. See [Startup Notification spec]( https://www.freedesktop.org/wiki/Specifications/startup-notification-spec/).", "type": "string" }, "TryExec": { "title": "Tryexec", + "description": "Filename or absolute path to an executable file on disk used to determine if the program is actually installed and can be run. If the test fails, the shortcut might be ignored / hidden.", + "markdownDescription": "Filename or absolute path to an executable file on disk used to determine if the program is actually installed and can be run. If the test fails, the shortcut might be ignored / hidden.", "type": "string" }, "glob_patterns": { "title": "Glob Patterns", + "description": "Map of custom MIME types to their corresponding glob patterns (e.g. `*.txt`). Only needed if you define custom MIME types in `MimeType`.", + "markdownDescription": "Map of custom MIME types to their corresponding glob patterns (e.g. `*.txt`). Only needed if you define custom MIME types in `MimeType`.", "type": "object", "additionalProperties": { "type": "string", @@ -251,7 +313,8 @@ } } }, - "additionalProperties": false + "additionalProperties": false, + "markdownDescription": "Linux-specific instructions.\n\nCheck the [Desktop entry specification]( https://specifications.freedesktop.org/desktop-entry-spec/latest/recognized-keys.html) for more details." }, "CFBundleURLTypesModel": { "title": "CFBundleURLTypesModel", @@ -260,6 +323,8 @@ "properties": { "CFBundleTypeRole": { "title": "Cfbundletyperole", + "description": "This key specifies the app's role with respect to the URL.", + "markdownDescription": "This key specifies the app's role with respect to the URL.", "enum": [ "Editor", "Viewer", @@ -270,6 +335,8 @@ }, "CFBundleURLSchemes": { "title": "Cfbundleurlschemes", + "description": "URL schemes / protocols handled by this type (e.g. 'mailto').", + "markdownDescription": "URL schemes / protocols handled by this type (e.g. 'mailto').", "type": "array", "items": { "type": "string" @@ -277,17 +344,22 @@ }, "CFBundleURLName": { "title": "Cfbundleurlname", + "description": "Abstract name for this URL type. Uniqueness recommended.", + "markdownDescription": "Abstract name for this URL type. Uniqueness recommended.", "type": "string" }, "CFBundleURLIconFile": { "title": "Cfbundleurliconfile", + "description": "Name of the icon image file (minus the .icns extension).", + "markdownDescription": "Name of the icon image file (minus the .icns extension).", "type": "string" } }, "required": [ "CFBundleURLSchemes" ], - "additionalProperties": false + "additionalProperties": false, + "markdownDescription": "Describes a URL scheme associated with the app." }, "CFBundleDocumentTypesModel": { "title": "CFBundleDocumentTypesModel", @@ -296,14 +368,20 @@ "properties": { "CFBundleTypeIconFile": { "title": "Cfbundletypeiconfile", + "description": "Name of the icon image file (minus the .icns extension).", + "markdownDescription": "Name of the icon image file (minus the .icns extension).", "type": "string" }, "CFBundleTypeName": { "title": "Cfbundletypename", + "description": "Abstract name for this document type. Uniqueness recommended.", + "markdownDescription": "Abstract name for this document type. Uniqueness recommended.", "type": "string" }, "CFBundleTypeRole": { "title": "Cfbundletyperole", + "description": "This key specifies the app's role with respect to the type.", + "markdownDescription": "This key specifies the app's role with respect to the type.", "enum": [ "Editor", "Viewer", @@ -314,6 +392,8 @@ }, "LSItemContentTypes": { "title": "Lsitemcontenttypes", + "description": "List of UTI strings defining a supported file type; e.g. for PNG files, use 'public.png'. See [UTI Reference]( https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html) for more info about the system-defined UTIs. Custom UTIs can be defined via 'UTExportedTypeDeclarations'. UTIs defined by other apps (not the system) need to be imported via 'UTImportedTypeDeclarations'.\n\nSee [Fun with UTIs](https://www.cocoanetics.com/2012/09/fun-with-uti/) for more info.", + "markdownDescription": "List of UTI strings defining a supported file type; e.g. for PNG files, use 'public.png'. See [UTI Reference]( https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html) for more info about the system-defined UTIs. Custom UTIs can be defined via 'UTExportedTypeDeclarations'. UTIs defined by other apps (not the system) need to be imported via 'UTImportedTypeDeclarations'.\n\nSee [Fun with UTIs](https://www.cocoanetics.com/2012/09/fun-with-uti/) for more info.", "type": "array", "items": { "type": "string" @@ -321,6 +401,8 @@ }, "LSHandlerRank": { "title": "Lshandlerrank", + "description": "Determines how Launch Services ranks this app among the apps that declare themselves editors or viewers of files of this type.", + "markdownDescription": "Determines how Launch Services ranks this app among the apps that declare themselves editors or viewers of files of this type.", "enum": [ "Owner", "Default", @@ -334,7 +416,8 @@ "LSItemContentTypes", "LSHandlerRank" ], - "additionalProperties": false + "additionalProperties": false, + "markdownDescription": "Describes a document type associated with the app." }, "UTTypeDeclarationModel": { "title": "UTTypeDeclarationModel", @@ -342,6 +425,8 @@ "properties": { "UTTypeConformsTo": { "title": "Uttypeconformsto", + "description": "The Uniform Type Identifier types that this type conforms to.", + "markdownDescription": "The Uniform Type Identifier types that this type conforms to.", "type": "array", "items": { "type": "string" @@ -349,22 +434,32 @@ }, "UTTypeDescription": { "title": "Uttypedescription", + "description": "A description for this type.", + "markdownDescription": "A description for this type.", "type": "string" }, "UTTypeIconFile": { "title": "Uttypeiconfile", + "description": "The bundle icon resource to associate with this type.", + "markdownDescription": "The bundle icon resource to associate with this type.", "type": "string" }, "UTTypeIdentifier": { "title": "Uttypeidentifier", + "description": "The Uniform Type Identifier to assign to this type.", + "markdownDescription": "The Uniform Type Identifier to assign to this type.", "type": "string" }, "UTTypeReferenceURL": { "title": "Uttypereferenceurl", + "description": "The webpage for a reference document that describes this type.", + "markdownDescription": "The webpage for a reference document that describes this type.", "type": "string" }, "UTTypeTagSpecification": { "title": "Uttypetagspecification", + "description": "A dictionary defining one or more equivalent type identifiers.", + "markdownDescription": "A dictionary defining one or more equivalent type identifiers.", "type": "object", "additionalProperties": { "type": "array", @@ -383,11 +478,13 @@ }, "MacOS": { "title": "MacOS", - "description": "Mac-specific instructions. Check these URLs for more info:\n\n- ``CF*`` keys: see `Core Foundation Keys `__\n- ``LS*`` keys: see `Launch Services Keys `__\n- ``entitlements``: see `Entitlements documentation `__", + "description": "Mac-specific instructions. Check these URLs for more info:\n\n- `CF*` keys: see [Core Foundation Keys](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html) - `LS*` keys: see [Launch Services Keys](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html) - `entitlements`: see [Entitlements documentation](https://developer.apple.com/documentation/bundleresources/entitlements)", "type": "object", "properties": { "name": { "title": "Name", + "description": "The name of the menu item. Can be a dictionary if the name depends on installation parameters. See `MenuItemNameDict` for details.", + "markdownDescription": "The name of the menu item. Can be a dictionary if the name depends on installation parameters. See `MenuItemNameDict` for details.", "anyOf": [ { "type": "string", @@ -400,15 +497,21 @@ }, "description": { "title": "Description", + "description": "A longer description of the menu item. Shown on popup messages.", + "markdownDescription": "A longer description of the menu item. Shown on popup messages.", "type": "string" }, "icon": { "title": "Icon", + "description": "Path to the file representing or containing the icon.", + "markdownDescription": "Path to the file representing or containing the icon.", "minLength": 1, "type": "string" }, "command": { "title": "Command", + "description": "Command to run with the menu item, expressed as a list of strings where each string is an argument.", + "markdownDescription": "Command to run with the menu item, expressed as a list of strings where each string is an argument.", "minItems": 1, "type": "array", "items": { @@ -417,52 +520,74 @@ }, "working_dir": { "title": "Working Dir", + "description": "Working directory for the running process. Defaults to user directory on each platform.", + "markdownDescription": "Working directory for the running process. Defaults to user directory on each platform.", "minLength": 1, "type": "string" }, "precommand": { "title": "Precommand", + "description": "(Simple, preferrably single-line) logic to run before the command is run. Runs before the environment is activated, if that applies.", + "markdownDescription": "(Simple, preferrably single-line) logic to run before the command is run. Runs before the environment is activated, if that applies.", "minLength": 1, "type": "string" }, "precreate": { "title": "Precreate", + "description": "(Simple, preferrably single-line) logic to run before the shortcut is created.", + "markdownDescription": "(Simple, preferrably single-line) logic to run before the shortcut is created.", "minLength": 1, "type": "string" }, "activate": { "title": "Activate", + "description": "Whether to activate the target environment before running `command`.", + "markdownDescription": "Whether to activate the target environment before running `command`.", "type": "boolean" }, "terminal": { "title": "Terminal", + "description": "Whether run the program in a terminal/console or not. On Windows, it only has an effect if `activate` is true. On MacOS, the application will ignore command-line arguments.", + "markdownDescription": "Whether run the program in a terminal/console or not. On Windows, it only has an effect if `activate` is true. On MacOS, the application will ignore command-line arguments.", "type": "boolean" }, "CFBundleDisplayName": { "title": "Cfbundledisplayname", + "description": "Display name of the bundle, visible to users and used by Siri. If not provided, 'menuinst' will use the 'name' field.", + "markdownDescription": "Display name of the bundle, visible to users and used by Siri. If not provided, 'menuinst' will use the 'name' field.", "type": "string" }, "CFBundleIdentifier": { "title": "Cfbundleidentifier", + "description": "Unique identifier for the shortcut. Typically uses a reverse-DNS format. If not provided, 'menuinst' will generate one from the 'name' field.", + "markdownDescription": "Unique identifier for the shortcut. Typically uses a reverse-DNS format. If not provided, 'menuinst' will generate one from the 'name' field.", "pattern": "^[A-z0-9\\-\\.]+$", "type": "string" }, "CFBundleName": { "title": "Cfbundlename", + "description": "Short name of the bundle. May be used if `CFBundleDisplayName` is absent. If not provided, 'menuinst' will generate one from the 'name' field.", + "markdownDescription": "Short name of the bundle. May be used if `CFBundleDisplayName` is absent. If not provided, 'menuinst' will generate one from the 'name' field.", "maxLength": 16, "type": "string" }, "CFBundleSpokenName": { "title": "Cfbundlespokenname", + "description": "Suitable replacement for text-to-speech operations on the app. For example, 'my app one two three' instead of 'MyApp123'.", + "markdownDescription": "Suitable replacement for text-to-speech operations on the app. For example, 'my app one two three' instead of 'MyApp123'.", "type": "string" }, "CFBundleVersion": { "title": "Cfbundleversion", + "description": "Build version number for the bundle. In the context of 'menuinst' this can be used to signal a new version of the menu item for the same application version.", + "markdownDescription": "Build version number for the bundle. In the context of 'menuinst' this can be used to signal a new version of the menu item for the same application version.", "pattern": "^\\S+$", "type": "string" }, "CFBundleURLTypes": { "title": "Cfbundleurltypes", + "description": "URL types supported by this app. Requires setting `event_handler` too. Note this feature requires macOS 10.14.4 or above.", + "markdownDescription": "URL types supported by this app. Requires setting `event_handler` too. Note this feature requires macOS 10.14.4 or above.", "type": "array", "items": { "$ref": "#/definitions/CFBundleURLTypesModel" @@ -470,6 +595,8 @@ }, "CFBundleDocumentTypes": { "title": "Cfbundledocumenttypes", + "description": "Document types supported by this app. Requires setting `event_handler` too. Requires macOS 10.14.4 or above.", + "markdownDescription": "Document types supported by this app. Requires setting `event_handler` too. Requires macOS 10.14.4 or above.", "type": "array", "items": { "$ref": "#/definitions/CFBundleDocumentTypesModel" @@ -477,15 +604,21 @@ }, "LSApplicationCategoryType": { "title": "Lsapplicationcategorytype", + "description": "The App Store uses this string to determine the appropriate categorization.", + "markdownDescription": "The App Store uses this string to determine the appropriate categorization.", "pattern": "^public\\.app-category\\.\\S+$", "type": "string" }, "LSBackgroundOnly": { "title": "Lsbackgroundonly", + "description": "Specifies whether this app runs only in the background.", + "markdownDescription": "Specifies whether this app runs only in the background.", "type": "boolean" }, "LSEnvironment": { "title": "Lsenvironment", + "description": "List of key-value pairs used to define environment variables.", + "markdownDescription": "List of key-value pairs used to define environment variables.", "type": "object", "additionalProperties": { "type": "string" @@ -493,23 +626,33 @@ }, "LSMinimumSystemVersion": { "title": "Lsminimumsystemversion", + "description": "Minimum version of macOS required for this app to run, as `x.y.z`. For example, for macOS v10.4 and later, use `10.4.0`.", + "markdownDescription": "Minimum version of macOS required for this app to run, as `x.y.z`. For example, for macOS v10.4 and later, use `10.4.0`.", "pattern": "^\\d+\\.\\d+\\.\\d+$", "type": "string" }, "LSMultipleInstancesProhibited": { "title": "Lsmultipleinstancesprohibited", + "description": "Whether an app is prohibited from running simultaneously in multiple user sessions.", + "markdownDescription": "Whether an app is prohibited from running simultaneously in multiple user sessions.", "type": "boolean" }, "LSRequiresNativeExecution": { "title": "Lsrequiresnativeexecution", + "description": "If true, prevent a universal binary from being run under Rosetta emulation on an Intel-based Mac.", + "markdownDescription": "If true, prevent a universal binary from being run under Rosetta emulation on an Intel-based Mac.", "type": "boolean" }, "NSSupportsAutomaticGraphicsSwitching": { "title": "Nssupportsautomaticgraphicsswitching", + "description": "If true, allows an OpenGL app to utilize the integrated GPU.", + "markdownDescription": "If true, allows an OpenGL app to utilize the integrated GPU.", "type": "boolean" }, "UTExportedTypeDeclarations": { "title": "Utexportedtypedeclarations", + "description": "The uniform type identifiers owned and exported by the app.", + "markdownDescription": "The uniform type identifiers owned and exported by the app.", "type": "array", "items": { "$ref": "#/definitions/UTTypeDeclarationModel" @@ -517,6 +660,8 @@ }, "UTImportedTypeDeclarations": { "title": "Utimportedtypedeclarations", + "description": "The uniform type identifiers inherently supported, but not owned, by the app.", + "markdownDescription": "The uniform type identifiers inherently supported, but not owned, by the app.", "type": "array", "items": { "$ref": "#/definitions/UTTypeDeclarationModel" @@ -524,6 +669,8 @@ }, "entitlements": { "title": "Entitlements", + "description": "List of permissions to request for the launched application. See [the entitlements docs]( https://developer.apple.com/documentation/bundleresources/entitlements) for a full list of possible values.", + "markdownDescription": "List of permissions to request for the launched application. See [the entitlements docs]( https://developer.apple.com/documentation/bundleresources/entitlements) for a full list of possible values.", "type": "array", "items": { "type": "string", @@ -532,6 +679,8 @@ }, "link_in_bundle": { "title": "Link In Bundle", + "description": "Paths that should be symlinked into the shortcut app bundle. It takes a mapping of source to destination paths. Destination paths must be relative. Placeholder `{{ MENU_ITEM_LOCATION }}` can be useful.", + "markdownDescription": "Paths that should be symlinked into the shortcut app bundle. It takes a mapping of source to destination paths. Destination paths must be relative. Placeholder `{{ MENU_ITEM_LOCATION }}` can be useful.", "type": "object", "additionalProperties": { "type": "string", @@ -540,11 +689,14 @@ }, "event_handler": { "title": "Event Handler", + "description": "Required shell script logic to handle opened URL payloads. Note this feature requires macOS 10.14.4 or above.", + "markdownDescription": "Required shell script logic to handle opened URL payloads. Note this feature requires macOS 10.14.4 or above.", "minLength": 1, "type": "string" } }, - "additionalProperties": false + "additionalProperties": false, + "markdownDescription": "Mac-specific instructions. Check these URLs for more info:\n\n- `CF*` keys: see [Core Foundation Keys](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html) - `LS*` keys: see [Launch Services Keys](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html) - `entitlements`: see [Entitlements documentation](https://developer.apple.com/documentation/bundleresources/entitlements)" }, "Windows": { "title": "Windows", @@ -553,6 +705,8 @@ "properties": { "name": { "title": "Name", + "description": "The name of the menu item. Can be a dictionary if the name depends on installation parameters. See `MenuItemNameDict` for details.", + "markdownDescription": "The name of the menu item. Can be a dictionary if the name depends on installation parameters. See `MenuItemNameDict` for details.", "anyOf": [ { "type": "string", @@ -565,15 +719,21 @@ }, "description": { "title": "Description", + "description": "A longer description of the menu item. Shown on popup messages.", + "markdownDescription": "A longer description of the menu item. Shown on popup messages.", "type": "string" }, "icon": { "title": "Icon", + "description": "Path to the file representing or containing the icon.", + "markdownDescription": "Path to the file representing or containing the icon.", "minLength": 1, "type": "string" }, "command": { "title": "Command", + "description": "Command to run with the menu item, expressed as a list of strings where each string is an argument.", + "markdownDescription": "Command to run with the menu item, expressed as a list of strings where each string is an argument.", "minItems": 1, "type": "array", "items": { @@ -582,44 +742,63 @@ }, "working_dir": { "title": "Working Dir", + "description": "Working directory for the running process. Defaults to user directory on each platform.", + "markdownDescription": "Working directory for the running process. Defaults to user directory on each platform.", "minLength": 1, "type": "string" }, "precommand": { "title": "Precommand", + "description": "(Simple, preferrably single-line) logic to run before the command is run. Runs before the environment is activated, if that applies.", + "markdownDescription": "(Simple, preferrably single-line) logic to run before the command is run. Runs before the environment is activated, if that applies.", "minLength": 1, "type": "string" }, "precreate": { "title": "Precreate", + "description": "(Simple, preferrably single-line) logic to run before the shortcut is created.", + "markdownDescription": "(Simple, preferrably single-line) logic to run before the shortcut is created.", "minLength": 1, "type": "string" }, "activate": { "title": "Activate", + "description": "Whether to activate the target environment before running `command`.", + "markdownDescription": "Whether to activate the target environment before running `command`.", "type": "boolean" }, "terminal": { "title": "Terminal", + "description": "Whether run the program in a terminal/console or not. On Windows, it only has an effect if `activate` is true. On MacOS, the application will ignore command-line arguments.", + "markdownDescription": "Whether run the program in a terminal/console or not. On Windows, it only has an effect if `activate` is true. On MacOS, the application will ignore command-line arguments.", "type": "boolean" }, "desktop": { "title": "Desktop", + "description": "Whether to create a desktop icon in addition to the Start Menu item.", "default": true, + "markdownDescription": "Whether to create a desktop icon in addition to the Start Menu item.", "type": "boolean" }, "quicklaunch": { "title": "Quicklaunch", + "description": "DEPRECATED. Whether to create a quick launch icon in addition to the Start Menu item.", "default": false, + "deprecated": true, + "markdownDescription": "DEPRECATED. Whether to create a quick launch icon in addition to the Start Menu item.", "type": "boolean" }, "terminal_profile": { "title": "Terminal Profile", + "description": "Name of the Windows Terminal profile to create. This name must be unique across multiple installations because menuinst will overwrite Terminal profiles with the same name.", + "markdownDescription": "Name of the Windows Terminal profile to create. This name must be unique across multiple installations because menuinst will overwrite Terminal profiles with the same name.", "minLength": 1, "type": "string" }, "url_protocols": { "title": "Url Protocols", + "description": "URL protocols that will be associated with this program.", + "markdownDescription": "URL protocols that will be associated with this program.", "type": "array", "items": { "type": "string", @@ -628,6 +807,8 @@ }, "file_extensions": { "title": "File Extensions", + "description": "File extensions that will be associated with this program.", + "markdownDescription": "File extensions that will be associated with this program.", "type": "array", "items": { "type": "string", @@ -636,29 +817,54 @@ }, "app_user_model_id": { "title": "App User Model Id", + "description": "Identifier used in Windows 7 and above to associate processes, files and windows with a particular application. If your shortcut produces duplicated icons, you need to define this field. If not set, it will default to `Menuinst.`.\n\nSee [AppUserModelID docs]( https://learn.microsoft.com/en-us/windows/win32/shell/appids#how-to-form-an-application-defined-appusermodelid) for more information on the required string format.", + "markdownDescription": "Identifier used in Windows 7 and above to associate processes, files and windows with a particular application. If your shortcut produces duplicated icons, you need to define this field. If not set, it will default to `Menuinst.`.\n\nSee [AppUserModelID docs]( https://learn.microsoft.com/en-us/windows/win32/shell/appids#how-to-form-an-application-defined-appusermodelid) for more information on the required string format.", "maxLength": 128, "pattern": "\\S+\\.\\S+", "type": "string" } }, - "additionalProperties": false + "additionalProperties": false, + "markdownDescription": "Windows-specific instructions. You can override global keys here if needed" }, "Platforms": { "title": "Platforms", - "description": "Platform specific options.\n\nNote each of these fields supports the same keys as the top-level :class:`MenuItem`\n(sans ``platforms`` itself), in case overrides are needed.", + "description": "Platform specific options.\n\nNote each of these fields supports the same keys as the top-level `MenuItem` (sans `platforms` itself), in case overrides are needed.", "type": "object", "properties": { "linux": { - "$ref": "#/definitions/Linux" + "title": "Linux", + "description": "Options for Linux. See `Linux` model for details.", + "markdownDescription": "Options for Linux. See `Linux` model for details.", + "allOf": [ + { + "$ref": "#/definitions/Linux" + } + ] }, "osx": { - "$ref": "#/definitions/MacOS" + "title": "Osx", + "description": "Options for macOS. See `MacOS` model for details.", + "markdownDescription": "Options for macOS. See `MacOS` model for details.", + "allOf": [ + { + "$ref": "#/definitions/MacOS" + } + ] }, "win": { - "$ref": "#/definitions/Windows" + "title": "Win", + "description": "Options for Windows. See `Windows` model for details.", + "markdownDescription": "Options for Windows. See `Windows` model for details.", + "allOf": [ + { + "$ref": "#/definitions/Windows" + } + ] } }, - "additionalProperties": false + "additionalProperties": false, + "markdownDescription": "Platform specific options.\n\nNote each of these fields supports the same keys as the top-level `MenuItem` (sans `platforms` itself), in case overrides are needed." }, "MenuItem": { "title": "MenuItem", @@ -667,6 +873,8 @@ "properties": { "name": { "title": "Name", + "description": "The name of the menu item. Can be a dictionary if the name depends on installation parameters. See `MenuItemNameDict` for details.", + "markdownDescription": "The name of the menu item. Can be a dictionary if the name depends on installation parameters. See `MenuItemNameDict` for details.", "anyOf": [ { "type": "string", @@ -679,10 +887,14 @@ }, "description": { "title": "Description", + "description": "A longer description of the menu item. Shown on popup messages.", + "markdownDescription": "A longer description of the menu item. Shown on popup messages.", "type": "string" }, "command": { "title": "Command", + "description": "Command to run with the menu item, expressed as a list of strings where each string is an argument.", + "markdownDescription": "Command to run with the menu item, expressed as a list of strings where each string is an argument.", "minItems": 1, "type": "array", "items": { @@ -691,36 +903,55 @@ }, "icon": { "title": "Icon", + "description": "Path to the file representing or containing the icon.", + "markdownDescription": "Path to the file representing or containing the icon.", "minLength": 1, "type": "string" }, "precommand": { "title": "Precommand", + "description": "(Simple, preferrably single-line) logic to run before the command is run. Runs before the environment is activated, if that applies.", + "markdownDescription": "(Simple, preferrably single-line) logic to run before the command is run. Runs before the environment is activated, if that applies.", "minLength": 1, "type": "string" }, "precreate": { "title": "Precreate", + "description": "(Simple, preferrably single-line) logic to run before the shortcut is created.", + "markdownDescription": "(Simple, preferrably single-line) logic to run before the shortcut is created.", "minLength": 1, "type": "string" }, "working_dir": { "title": "Working Dir", + "description": "Working directory for the running process. Defaults to user directory on each platform.", + "markdownDescription": "Working directory for the running process. Defaults to user directory on each platform.", "minLength": 1, "type": "string" }, "activate": { "title": "Activate", + "description": "Whether to activate the target environment before running `command`.", "default": true, + "markdownDescription": "Whether to activate the target environment before running `command`.", "type": "boolean" }, "terminal": { "title": "Terminal", + "description": "Whether run the program in a terminal/console or not. On Windows, it only has an effect if `activate` is true. On MacOS, the application will ignore command-line arguments.", "default": false, + "markdownDescription": "Whether run the program in a terminal/console or not. On Windows, it only has an effect if `activate` is true. On MacOS, the application will ignore command-line arguments.", "type": "boolean" }, "platforms": { - "$ref": "#/definitions/Platforms" + "title": "Platforms", + "description": "Platform-specific options. Presence of a platform field enables menu items in that platform.", + "markdownDescription": "Platform-specific options. Presence of a platform field enables menu items in that platform.", + "allOf": [ + { + "$ref": "#/definitions/Platforms" + } + ] } }, "required": [ @@ -729,7 +960,8 @@ "command", "platforms" ], - "additionalProperties": false + "additionalProperties": false, + "markdownDescription": "Instructions to create a menu item across operating systems." } } } diff --git a/news/281-fields b/news/281-fields new file mode 100644 index 00000000..cccbbfa9 --- /dev/null +++ b/news/281-fields @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Make sure the Pydantic field descriptions make it to the generated JSON schema. (#281) + +### Deprecations + +* + +### Docs + +* + +### Other + +*