Commit Graph
198 Commits
Author SHA1 Message Date
David Sangrey 832020981d Update PLUGINS.md 2026-01-20 21:35:22 -05:00
David Sangrey cb93822470 Update Docs Pass 2026-01-19 12:22:24 -05:00
David Sangrey 6192803d61 Add VERSION check 2025-12-25 17:18:15 -05:00
David Sangrey 13b47c2174 Add Plugin Naming Warning 2025-12-09 21:39:14 -05:00
Inutt f4e70dbe5b Add documentation for relative plugin imports
diff --git a/PLUGINS.md b/PLUGINS.md
index 6fd20ef9..71aaec7a 100644
--- a/PLUGINS.md
+++ b/PLUGINS.md
@@ -163,6 +163,19 @@ circular imports.
 For an example of how this is done, look at the code in `plugins/common_coreutils.py`
 and the usage of these functions in other core plugins.

+Plugins may import additional code modules from `load.py` in the usual way. Note
+that using an import statement like `import my_module` or `from my_module import
+foo` will only import one module with that name **across all plugins**. This can
+be used to create a shared library used by several plugins if used carefully,
+but may create a conflict if another plugin also has a module of the same name
+containing different code. For example if two plugins both contain a
+`widgets.py` file and both do `import widgets`, only one of the two modules will
+actually be imported.
+
+To avoid this issue, use a relative import statement such as `import .widgets`
+or `from .widgets import foo` to ensure that the module is loaded from the
+current plugin, even if the name conflicts with another plugin's code.
+
 ---

 ## Logging
2025-11-24 20:14:51 +00:00
David Sangrey 3063bbb94f [#2378] Update PLUGINS Example 2025-05-03 19:52:14 -04:00
David Sangrey a93389c3d4 [Docs] Update PLUGINS.md on how to use common functions 2025-04-18 01:02:28 -04:00
David Muckle 317d9fa32b Revert "Remove extra newline"
This reverts commit 529cf68db0.
2025-02-23 11:31:11 -05:00
David Muckle 529cf68db0 Remove extra newline 2025-02-23 10:57:09 -05:00
David Muckle 3c22aad254 Update PLUGINS.md with new info about Powerplay in state 2025-02-22 17:52:22 -05:00
Connor 583ee4fa50 Update PLUGINS.md
update state table to match newly added values from loadout events
2024-12-27 20:40:41 +00:00
aussig 2dba5e4365 Merge branch 'develop' into enhancement/2188/translation-override 2024-05-12 13:34:42 +01:00
David Sangrey 91e4e7998b [1812] Update Docs and Fix Compat Layer 2024-04-22 19:18:01 -04:00
David Sangrey 10be2c2031 [Docs] Update Plugin Docs 2024-04-22 18:32:19 -04:00
aussig a863cebc66 [2188] Add optional lang parameter to l10n.Translations.translate() to allow language to be overridden. 2024-04-01 07:48:15 +01:00
Athanasius 27e39a05d8 PLUGINS: Document using config.user_agent for User-Agent
And, really, just use `timeout_session` anyway, which does this.
2023-01-18 11:48:27 +00:00
Athanasius 8b9379a89e PLUGINS: Document that they should use requests, not urllib, and why 2023-01-18 11:44:51 +00:00
Athanasius 650b43cc3c PLUGINS: Document monitor.is_live_galaxy() as sanctioned for use 2023-01-18 11:30:28 +00:00
Athanasius ef1642181a monitor/tracking: Move .stationtype to state['StationType']
* Nothing outside of monitor.py uses this, but it's of the same nature as
  StationName and MarketID, so do this for consistency.

For now we'll leave monitor.stationservices as-is.
2023-01-11 19:44:45 +00:00
Athanasius 31e8d0372d monitor/tracking: Move .station_marketid to state['MarketID']
1. plugins/eddb.py uses this for MarketID-based station URLs.

* So do the 'rename'.
* Remove EDDB tracking in favour of this.
* Update PLUGINS.md
2023-01-11 19:44:44 +00:00
Athanasius dde0cf876c monitor/tracking: Move .station to state['StationName']
1. EDDB tracks this.

* So move monitor.station to monitor.state['StationName'].
* PLUGINS.md updated to cite this.
2023-01-11 19:44:41 +00:00
Athanasius df5eb5b270 monitor/tracking: Switch .systempopulation to state['SystemPopulation']
1. EDDB plugin tracked this for keeping the Station link text up to date.

* So moved it to monitor.state['SystemPopulation'].
* PLUGINS.md updated to cite this.
* PLUGINS.md also updated to note state entries that are set to None if
  remote multi-crew is detected.
2023-01-11 19:44:14 +00:00
Athanasius b1308e4f28 PLUGINS.md: Document addition of Bodt(ID|Type) and the caveats about use 2023-01-11 19:43:24 +00:00
Athanasius 86b0aa4550 monitor: Track all System and Body state in monitor.state
* Minor grammar edit only in PLUGINS.md (I was checking if it explicitly
  stated what data is expected in the synthetic 'StartUp' event, it doesn't).
* First changes to move some monitor properties into the monitor.state
  dictionary.  This is for system or body data.
* Re-factored the generation of 'StartUp' event into
  `EDLogs.synthesize_startup_event()`.  It's done in two places, so was
  anti-DRY.
* In general any bulk setting of system & body data is now done in the
  same order for comparison clarity.
* A little of the location tracking has been duplicated from plugins/eddn.py.
  This is with a view to switching *it* to using the state version.
2023-01-11 19:43:14 +00:00
Athanasius 991f69044c PLUGINS.md: Avoid an example implying plugins can set main status text
The 'Error messages' section lays out how to get a message into the main
UI status area, and it does *not* say to try setting it directly.
2022-12-31 17:20:30 +00:00
aussig 16055a311f Typo in plugins docs 2022-12-26 11:23:44 +00:00
aussig f6f122072b Tweaks to plugins docs for fleetcarrier CAPI, including headings, typos and clarity on legacy galaxy 2022-12-26 11:20:37 +00:00
aussig e22fa7c23b Store cmdr name at request time in CAPIData instead of passing into EDMCCAPIRequest and EDMCCAPIResponse 2022-12-24 09:32:45 +00:00
aussig 3c8eca16af Revert unnoticed whitespace modifications to PLUGINS.py 2022-12-23 13:01:47 +00:00
aussig 7e726e606a Store original request cmdr name in 'request_cmdr' in CAPIData 2022-12-23 12:47:35 +00:00
aussig 9e17c46b25 Implement suggestions from PR #1773. 2022-12-22 16:21:42 +00:00
aussig a551da59a3 Documentation for capi_fleetcarrier() plugin callback function 2022-12-22 08:57:50 +00:00
Athanasius ba68397b3f CAPI killswitches: endpoint killswitches & eddn export ones too
* Added `capi.request.<endpoint>` killswitches at appropriate call points.
* Added `eddn.capi_export.<type>` killswitches.  This allows for killing
  just the EDDN export of such CAPI-derived data, without stopping the actual
  queries, as other plugins/functionality might still have harmless use of
  the data.
* PLUGINS.md: Actually describe the contents of `data` passed to plugins, and
  point out it might not always contain market or shipyard data.  This is
  not only because of the new killswitches, but could already have happened
  if the station/port docked at didn't have the services.
* Some misc typing cleanups.
2022-12-16 15:06:01 +00:00
Athanasius e2f4f8f665 PLUGINS.md: Slightly improve CAPI Legacy/Live doc 2022-12-14 13:51:29 +00:00
Athanasius 605ad07aac Merge pull request #1747 from EDCD/enhancement/1728/capi-for-legacy
CAPI: Enable use of Legacy host when applicable.
2022-12-14 10:42:05 +00:00
Athanasius 84615db839 PLUGINS.md: Allow use of CAPIData.source_host
* Additional Allowed Imports `from companion ...`.

* Plugin authors will still need to chain `cmdr_data_legacy()` to calling
  `cmdr_data()`, but with sanctioned access to `data.source_host` they can
  then determine the galaxy data source.

* Re-worked the documentation for CAPI data a little to make all of this as
  clear as possible.
2022-12-08 13:17:13 +00:00
Athanasius af5d998464 PLUGINS.md: Correct the statement about python stdlib 2022-12-08 12:59:36 +00:00
Athanasius a3a52055d3 CAPI/PLUGINS.md: Document cmdr_data_legacy()
For now warn against trying to use extra CAPIData properties to determine
the galaxy.
2022-12-08 12:53:31 +00:00
Athanasius 3e15aa0fe6 PLUGINS.md: More fully document state['NavRoute'
This includes the "catching up" load of the data.
2022-12-06 15:42:59 +00:00
Athanasius b4c4e44cb7 eddn/CAPI: Use a common function for game_version strings
* This did, however, remind me that the `data` passed into `cmdr_data()`
  is an amalgam of `/profile`, `/market` and `/shipyard` queries.

  This means that the data.source_endpoint is **not correct for all of
  the data and its use**.  As such I had to pass 'hard coded' values into
  the function from the various CAPI export functions.  They know what it
  is they're exporting.

* As this reminded me that "CAPI `data` is actually a `CAPIDATA`", I've
  documented that in PLUGINS.md, but with a dire warning against relying on
  any of the extra properties.
2022-12-01 16:42:06 +00:00
Athanasius b06e579754 PLUGINS.md: Emphasise limited use of from config import config 2022-12-01 12:14:49 +00:00
Athanasius 0eb33e011b PLUGINS.md: Document new IsDocked state flag. 2022-11-23 15:57:25 +00:00
Athanasius fa834daaca PLUGINS.md: Fix example return type hint for journal_entry()
It's `Optional[str]` for possible error string being returned.
2022-08-15 08:39:34 +01:00
Athanasius 1bb0bf9f74 PLUGINS.md: Document NavRouteClear behaviour 2022-08-10 11:47:51 +01:00
Athanasius 7116964dba PLUGINS: Call out keeping an eye on Discussions 2022-02-17 12:19:36 +00:00
Athanasius 785f9a3235 PLUGINS.md: We don't currently include all of Python stdlib 2021-11-16 11:07:32 +00:00
Athanasius 945baf7f53 Merge branch 'stable' 2021-10-25 11:12:39 +01:00
Athanasius cf5806021e PLUGINS.md: capi_is_horizons() now 2021-10-18 12:33:11 +01:00
Chris 5e5169da51 Fix shutting_down example in plugins.md 2021-08-25 15:03:19 -04:00
Chris 705d2dd4f1 Fix game_runnning() doc in PLUGINS.md 2021-08-24 14:52:10 -04:00