Module:Territories/data/doc: Difference between revisions

From NPOWiki
Jump to navigation Jump to search
create
 
(No difference)

Latest revision as of 02:00, 8 September 2025

This page contains the documentation for Module:Territories/data. It includes information about the module, such as usage and categories, and is not displayed when using the module itself.

This is a data module to be used with mw.loadData.

To do: write script to generate since there are so many, didn't realize when starting.

How to generate

  1. Edit the module data page and delete everything except the comment at the top and the word return followed by a space.
  2. Go to the API v2 page and have a Public access key ready.
  3. Click the "Try it out" button. For ids, select nothing ( -- ). The remaining fields need to be blank. Paste in your key and Execute.
  4. Click the copy button in the response box (not the example below it) and paste into the edit box. Delete the line at the top that starts with "territory".
  5. At the bottom, in the _metadata object, on the line that says "next", make a note of the value after offset=.
  6. Delete the whole metadata object as well as the line above it ( ], ), then type a comma at the end of the previous line so it looks like this: ( }, ) and press Enter to create a new line.
  7. On the API page, enter the offset value into the offset field and Execute again.
  8. This time, only copy everything starting below the line at the top that starts with "territory" (so the single { and not the space before it), down to but not including the line that starts with "_metadata". Also do not include the line above it ( ], ).
  9. Paste into the edit box on a new line after the comma you added.
  10. Repeat the set of five steps before this one until the "next" line in the metadata does not contain a URL (the offset will be around 4000).
  11. The only line following the last set of data should be a single closing brace ( } ) with no indent.
  12. Copy the entire contents of the edit box into a text editor and make the following plaintext replacements: (two spaces) -> \t (tab character - how to input depends on editor), [ -> {, ] -> }, and regular expression replacement: "(territory|id|sector|size|density|slots|respect|coordinates|x|y|neighbors)": -> $1 =, then unindent everything by one level.
  13. Update the date in the comment at the top and save. Keep a backup copy in your text editor in case it fails.