From f8ef75f3d68347cadeb051cf768e7b81e1cf987f Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Sun, 28 Jan 2024 17:28:14 +0000 Subject: [PATCH] build based on 7dd3a41 --- dev/.documenter-siteinfo.json | 2 +- dev/api/index.html | 12 ++++++------ dev/creating/index.html | 2 +- dev/formats/index.html | 2 +- dev/index.html | 2 +- dev/usage/index.html | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 7fbbc5e..0e62838 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-28T17:23:35","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-28T17:28:10","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index 52995e8..d3b6524 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -5,11 +5,11 @@ ".toml" => MIME("application/toml"), ".txt.gz" => MIME("text/x-intersphinx+gzip"), ".toml.gz" => MIME("application/toml+gzip"), -)source
DocInventories.InventoryType

An inventory link targets in a project documentation.

inventory = Inventory(
+)
source
DocInventories.InventoryType

An inventory link targets in a project documentation.

inventory = Inventory(
     source;
     mime=auto_mime(source),
     root_url=root_url(source)
-)

loads an inventory file from the given source, which can be a URL or the path to a local file. If it is a URL, the options timeout (seconds to wait for network connections), retries (number of times to retry) and wait_time (seconds longer to wait between each retry) may be given. The source must contain data in the given mime type. By default, the mime type is derived from the file extension, via auto_mime.

The Inventory acts as a collection of InventoryItems, representing all the objects, sections, or other linkable items in the online documentation of a project.

Alternatively,

inventory = Inventory(; project, version="", root_url="", items=[])

with a mandatory project argument instantiates an inventory with the IventoryItems in items. If items is not given, the resulting empty inventory can have InventoryItems added afterwards via push!.

Attributes

  • project: The name of the project
  • version: The version of the project (e.g., "1.0.0")
  • root_url: The root URL to which the item.uri of any InventoryItem is relative. If not empty, should start with "https://" and end with a slash.
  • source: The URL or filename from which the inventory was loaded, or a comment if the inventory was constructed otherwise.
  • sorted: A boolean to indicate whether the items are sorted by their name attribute, allowing for efficient lookup. This is true for all inventories loaded from a URL or file and false for manually instantiated inventories.

Item access

Items can be accessed via iteration (for item in inventory), by numeric index (inventory[1], inventory[2], … inventory[end]), or by lookup: inventory[name] or inventory[spec], where spec is a string of the form ":[domain:]role:`name`", see the discussion of spec in InventoryItem. The lookup delegates to find_in_inventory with quiet=true and takes into account item.priority.

Search

The inventory can be searched by calling inventory(search; include_hidden_priority=true). This returns a list of all items that contain search in spec(item) or repr(item; context=(:full => true)). Typically, search would be a string or a Regex. Some examples for common searches:

  • A spec of the form ":domain:role:`name`", in full, partially, or as a regex.
  • Part of a url of a page in the project's documentation, as a string
  • The title of a section as it appears somewhere in the project's documentation.

The search results are sorted by abs(item.priority). If include_hidden_priority=false, negative item.priority values are omitted.

Methods

source
DocInventories.InventoryFormatErrorType

An error indicating an issue with an objects.inv file.

throw(InventoryFormatError(msg))
source
DocInventories.InventoryItemType

An item inside an Inventory.

item = InventoryItem(; name, role, uri, priority=1, domain="jl", dispname="-")

represents a linkable item inside a project documentation, referenced by name. The domain and role take their semantics from the Sphinx project, see Attributes for details on these parameters, as well as priority and dispname. The uri is relative to a project root, which should be the Inventory.root_url of the inventory containing the InventoryItem.

For convenience, an InventoryItem can also be instantiated from a mapping spec => uri, where spec=":domain:role:`name`" borrows from Sphinx' cross-referencing syntax:

item = IventoryItem(
+)

loads an inventory file from the given source, which can be a URL or the path to a local file. If it is a URL, the options timeout (seconds to wait for network connections), retries (number of times to retry) and wait_time (seconds longer to wait between each retry) may be given. The source must contain data in the given mime type. By default, the mime type is derived from the file extension, via auto_mime.

The Inventory acts as a collection of InventoryItems, representing all the objects, sections, or other linkable items in the online documentation of a project.

Alternatively,

inventory = Inventory(; project, version="", root_url="", items=[])

with a mandatory project argument instantiates an inventory with the IventoryItems in items. If items is not given, the resulting empty inventory can have InventoryItems added afterwards via push!.

Attributes

  • project: The name of the project
  • version: The version of the project (e.g., "1.0.0")
  • root_url: The root URL to which the item.uri of any InventoryItem is relative. If not empty, should start with "https://" and end with a slash.
  • source: The URL or filename from which the inventory was loaded, or a comment if the inventory was constructed otherwise.
  • sorted: A boolean to indicate whether the items are sorted by their name attribute, allowing for efficient lookup. This is true for all inventories loaded from a URL or file and false for manually instantiated inventories.

Item access

Items can be accessed via iteration (for item in inventory), by numeric index (inventory[1], inventory[2], … inventory[end]), or by lookup: inventory[name] or inventory[spec], where spec is a string of the form ":[domain:]role:`name`", see the discussion of spec in InventoryItem. The lookup delegates to find_in_inventory with quiet=true and takes into account item.priority.

Search

The inventory can be searched by calling inventory(search; include_hidden_priority=true). This returns a list of all items that contain search in spec(item) or repr(item; context=(:full => true)). Typically, search would be a string or a Regex. Some examples for common searches:

  • A spec of the form ":domain:role:`name`", in full, partially, or as a regex.
  • Part of a url of a page in the project's documentation, as a string
  • The title of a section as it appears somewhere in the project's documentation.

The search results are sorted by abs(item.priority). If include_hidden_priority=false, negative item.priority values are omitted.

Methods

source
DocInventories.InventoryFormatErrorType

An error indicating an issue with an objects.inv file.

throw(InventoryFormatError(msg))
source
DocInventories.InventoryItemType

An item inside an Inventory.

item = InventoryItem(; name, role, uri, priority=1, domain="jl", dispname="-")

represents a linkable item inside a project documentation, referenced by name. The domain and role take their semantics from the Sphinx project, see Attributes for details on these parameters, as well as priority and dispname. The uri is relative to a project root, which should be the Inventory.root_url of the inventory containing the InventoryItem.

For convenience, an InventoryItem can also be instantiated from a mapping spec => uri, where spec=":domain:role:`name`" borrows from Sphinx' cross-referencing syntax:

item = IventoryItem(
     ":domain:role:`name`" => uri;
     dispname=<name>,
     priority=(<domain == "std" ? -1 : 1>)
@@ -17,13 +17,13 @@
     "title" => uri;
     dispname=<title>,
     priority=-1
-)

indicates a link to a section header in the documentation of a project. The name will be a sluggified version of the title, making the item equivalent to item = IventoryItem(":std:label:`name`" => uri; dispname=title, priority=-1).

Attributes

  • name: The object name for referencing. For code objects, this should be the fully qualified name. For section names, it may be a slugified version of the section title. It must have non-zero length.

  • domain: The name of a Sphinx domain. Should be "jl" for Julia code objects (default), "py" for Python code objects, and "std" for text objects such as section names. Must have non-zero length, and must not contain whitespace or a colon.

  • role: A domain-specific role (type). Must have nonzero length and not contain whitespace.

  • priority: An integer flag for placement in search results. Used when searching in an Inventory, for item access in an Inventory, and with find_in_inventory. The following flag values are supported:

    • 1: the "default" priority. Used by default for all objects not in the "std" domain (that is, all "code" objects such as those in the "jl" domain).
    • 0: object is important
    • 2 (or higher): object is unimportant
    • -1 (or lower): object is "hidden" (may be omitted from search). Used by default for all objects in the std domain (section titles)

    See find_in_inventory for details. The above semantics match those used by Sphinx.

  • uri: A URI for the location of the object's documentation, relative to the location of the inventory file containing the item. Must not contain whitespace. May end with "$" to indicate a placeholder for name (usually as "#$", for an HTML anchor matching name).

  • dispname: A full plain text representation of the object. May be "-" if the display name is identical to name (which it should be for code objects). For section titles, this should be the plain text of the title, without formatting, but not slugified.

Methods

  • uri – Extract the full URI, resolving the $ placeholder and prepending a root_url, if applicable.
  • dispname – Extract the dispname, resolving the "-" shorthand, if applicable.
  • spec – Return the specification string ":domain:role:`name`" associated with the item
source
DocInventories.auto_mimeMethod

Determine the MIME type of the given file path or URL from the file extension.

mime = auto_mime(source)

returns a MIME type from the extension of source. The default mapping is in MIME_TYPES.

Unknown or unsupported extensions throw an ArgumentError.

source
DocInventories.dispnameMethod

Obtain the full display name for an InventoryItem.

display_name = dispname(item)

returns item.dispname with "-" expanded to item.name.

source
DocInventories.find_in_inventoryMethod

Find an item in the inventory.

item = find_in_inventory(
+)

indicates a link to a section header in the documentation of a project. The name will be a sluggified version of the title, making the item equivalent to item = IventoryItem(":std:label:`name`" => uri; dispname=title, priority=-1).

Attributes

  • name: The object name for referencing. For code objects, this should be the fully qualified name. For section names, it may be a slugified version of the section title. It must have non-zero length.

  • domain: The name of a Sphinx domain. Should be "jl" for Julia code objects (default), "py" for Python code objects, and "std" for text objects such as section names. Must have non-zero length, and must not contain whitespace or a colon.

  • role: A domain-specific role (type). Must have nonzero length and not contain whitespace.

  • priority: An integer flag for placement in search results. Used when searching in an Inventory, for item access in an Inventory, and with find_in_inventory. The following flag values are supported:

    • 1: the "default" priority. Used by default for all objects not in the "std" domain (that is, all "code" objects such as those in the "jl" domain).
    • 0: object is important
    • 2 (or higher): object is unimportant
    • -1 (or lower): object is "hidden" (may be omitted from search). Used by default for all objects in the std domain (section titles)

    See find_in_inventory for details. The above semantics match those used by Sphinx.

  • uri: A URI for the location of the object's documentation, relative to the location of the inventory file containing the item. Must not contain whitespace. May end with "$" to indicate a placeholder for name (usually as "#$", for an HTML anchor matching name).

  • dispname: A full plain text representation of the object. May be "-" if the display name is identical to name (which it should be for code objects). For section titles, this should be the plain text of the title, without formatting, but not slugified.

Methods

  • uri – Extract the full URI, resolving the $ placeholder and prepending a root_url, if applicable.
  • dispname – Extract the dispname, resolving the "-" shorthand, if applicable.
  • spec – Return the specification string ":domain:role:`name`" associated with the item
source
DocInventories.auto_mimeMethod

Determine the MIME type of the given file path or URL from the file extension.

mime = auto_mime(source)

returns a MIME type from the extension of source. The default mapping is in MIME_TYPES.

Unknown or unsupported extensions throw an ArgumentError.

source
DocInventories.dispnameMethod

Obtain the full display name for an InventoryItem.

display_name = dispname(item)

returns item.dispname with "-" expanded to item.name.

source
DocInventories.find_in_inventoryMethod

Find an item in the inventory.

item = find_in_inventory(
     inventory,
     name;
     domain="",
     role="",
     quiet=false,
     include_hidden_priority=true
-)

returns the top priority InventoryItem matching the given name. If the inventory contains no matching item, returns nothing.

Arguments

  • inventory: The Inventory to search.
  • name: The value of the name attribute of the InventoryItem to find. Must match exactly.
  • domain: If not empty, restrict search to items with a matching domain attribute.
  • role: If not empty, restrict search to items with a matching role attribute.
  • quiet: If false (default), log a warning if the item specification is ambiguous (the top priority item of multiple candidates is returned). If no matching item can be found, an error will be logged in addition to returning nothing.
  • include_hidden_priority: Whether or not to consider items with a negative priority attribute. If "hidden" items are included (default), they are sorted by the absolute value of the priority. That is, items with priority=-1 and priority=1 are considered to be equivalent.

Note that direct item lookup as inventory[spec] where spec is a string of the form "[:[domain:]role:]`name`" is available as a simplified way to call find_in_inventory with quiet=true.

source
DocInventories.root_urlMethod

Obtain the root url from an inventory source.

url = root_url(source; warn=true)

returns the root url as determined by split_url if source starts with "https://" or "http://", or an empty string otherwise (if source is a local file path). An empty root url will emit a warning unless warn=false.

source
DocInventories.saveMethod

Write the Inventory to file in the specified format.

save(filename, inventory; mime=auto_mime(filename))

writes inventory to filename in the specified MIME type. By default, the MIME type is derived from the file extension of filename via auto_mime.

source
DocInventories.show_fullMethod
show_full(item)  # io=stdout
-show_full(io, item)

is equivalent to

show(IOContext(io, :full => true), "text/plain", item)

and shows the InventoryItem with all attributes.

source
DocInventories.show_fullMethod
show_full(inventory)  # io=stdout
-show_full(io, inventory)

is equivalent to

show(IOContext(io, :limit => false), "text/plain", inventory)

and shows the entire inventory without truncating the list of items. This may produce large output, so you may want to make use of the TerminalPager package.

source
DocInventories.specMethod

Return the specification string of an InventoryItem.

item_spec = spec(item)

returns a string of the form ":domain:role:`name`" using the attributes of the given item.

source
DocInventories.split_urlMethod

Split a URL into a root URL and a filename.

root_url, filename = split_url(url)

splits url at the last slash. This behaves like splitdir, but operates on URLs instead of file paths. The URL must start with "https://" or "http://".

source
DocInventories.uriMethod
uri_str = uri(inventory, key)

is equivalent to uri(inventory[key]; root_url=inventory.root_url).

source
DocInventories.uriMethod
uri_str = uri(item; root_url="")

fully expands item.uri and prepends root_url.

source
+)

returns the top priority InventoryItem matching the given name. If the inventory contains no matching item, returns nothing.

Arguments

Note that direct item lookup as inventory[spec] where spec is a string of the form "[:[domain:]role:]`name`" is available as a simplified way to call find_in_inventory with quiet=true.

source
DocInventories.root_urlMethod

Obtain the root url from an inventory source.

url = root_url(source; warn=true)

returns the root url as determined by split_url if source starts with "https://" or "http://", or an empty string otherwise (if source is a local file path). An empty root url will emit a warning unless warn=false.

source
DocInventories.saveMethod

Write the Inventory to file in the specified format.

save(filename, inventory; mime=auto_mime(filename))

writes inventory to filename in the specified MIME type. By default, the MIME type is derived from the file extension of filename via auto_mime.

source
DocInventories.show_fullMethod
show_full(item)  # io=stdout
+show_full(io, item)

is equivalent to

show(IOContext(io, :full => true), "text/plain", item)

and shows the InventoryItem with all attributes.

source
DocInventories.show_fullMethod
show_full(inventory)  # io=stdout
+show_full(io, inventory)

is equivalent to

show(IOContext(io, :limit => false), "text/plain", inventory)

and shows the entire inventory without truncating the list of items. This may produce large output, so you may want to make use of the TerminalPager package.

source
DocInventories.specMethod

Return the specification string of an InventoryItem.

item_spec = spec(item)

returns a string of the form ":domain:role:`name`" using the attributes of the given item.

source
DocInventories.split_urlMethod

Split a URL into a root URL and a filename.

root_url, filename = split_url(url)

splits url at the last slash. This behaves like splitdir, but operates on URLs instead of file paths. The URL must start with "https://" or "http://".

source
DocInventories.uriMethod
uri_str = uri(inventory, key)

is equivalent to uri(inventory[key]; root_url=inventory.root_url).

source
DocInventories.uriMethod
uri_str = uri(item; root_url="")

fully expands item.uri and prepends root_url.

source
diff --git a/dev/creating/index.html b/dev/creating/index.html index 6f901f5..386f1b1 100644 --- a/dev/creating/index.html +++ b/dev/creating/index.html @@ -31,4 +31,4 @@ [[std.doc]] dispname = "Python (programming language)" name = "Python" -uri = "Python_(programming_language)"

The requirements for the file are in the description of the TOML Format, but should be fairly intuitive.

In general, custom inventory files should be stored as an uncompressed .toml file. This makes them much easier to maintain with a text editor. In addition, these inventories will presumably be checked into a git repository, which will be much more efficient with uncompressed (diffable!) text-based files.

In contrast, inventories that are deployed (put online so that other projects may download them to resolve links) should always be compressed, either as an objects.inv file or as an inventory.toml.gz file.

+uri = "Python_(programming_language)"

The requirements for the file are in the description of the TOML Format, but should be fairly intuitive.

In general, custom inventory files should be stored as an uncompressed .toml file. This makes them much easier to maintain with a text editor. In addition, these inventories will presumably be checked into a git repository, which will be much more efficient with uncompressed (diffable!) text-based files.

In contrast, inventories that are deployed (put online so that other projects may download them to resolve links) should always be compressed, either as an objects.inv file or as an inventory.toml.gz file.

diff --git a/dev/formats/index.html b/dev/formats/index.html index 1b9c1aa..7c4e814 100644 --- a/dev/formats/index.html +++ b/dev/formats/index.html @@ -8,4 +8,4 @@ name = "<name>" uri = "<uri>" dispname = "<dispname>" -priority = <priority>

The four lines for name, uri, dispname, and priority may occur in any order. Also, for items with the default priority (-1 for the std domain, 1 otherwise), the priority line may be omitted. If dispname is equal to name (usually indicated by dispname="-"), the dispname line may also be omitted.

The item-blocks may be grouped/separated by blank lines. In .toml files generated by DocInventories.save("inventory.toml", inventory) items will be grouped into blocks with the same [[<domain>.<role>]] with a blank line between each block.

Any TOML parser should read a .toml file with the above structure into a nested dictionary, so that item_dict = toml_data[domain][role][i] corresponds to the i'th inventory item with the given domain and role. That item_dict will then map "name", "uri", and potentially "dispname" and "priority" to their respective values.

A compressed TOML file can be written with, e.g., DocInventories.save("inventory.toml.gz", inventory). With compression, the size of the file should be comparable (albeit slightly larger) than the compressed objects.inv format.

Size Comparison

In the following table, we compare the size of the inventory file of different projects in kilobytes, for the various output formats.

ProjectNo. of Objects.txt.toml.inv.toml.gz
Documenter48353.1 kB64.1 kB8.3 kB8.5 kB
Julia3602250.0 kB324.6 kB45.0 kB45.9 kB
Matplotlib104061110.3 kB1323.3 kB105.9 kB110.8 kB
Python164491083.4 kB1396.7 kB140.6 kB146.7 kB
+priority = <priority>

The four lines for name, uri, dispname, and priority may occur in any order. Also, for items with the default priority (-1 for the std domain, 1 otherwise), the priority line may be omitted. If dispname is equal to name (usually indicated by dispname="-"), the dispname line may also be omitted.

The item-blocks may be grouped/separated by blank lines. In .toml files generated by DocInventories.save("inventory.toml", inventory) items will be grouped into blocks with the same [[<domain>.<role>]] with a blank line between each block.

Any TOML parser should read a .toml file with the above structure into a nested dictionary, so that item_dict = toml_data[domain][role][i] corresponds to the i'th inventory item with the given domain and role. That item_dict will then map "name", "uri", and potentially "dispname" and "priority" to their respective values.

A compressed TOML file can be written with, e.g., DocInventories.save("inventory.toml.gz", inventory). With compression, the size of the file should be comparable (albeit slightly larger) than the compressed objects.inv format.

Size Comparison

In the following table, we compare the size of the inventory file of different projects in kilobytes, for the various output formats.

ProjectNo. of Objects.txt.toml.inv.toml.gz
Documenter48353.1 kB64.1 kB8.3 kB8.5 kB
Julia3602250.0 kB324.6 kB45.0 kB45.9 kB
Matplotlib104061110.3 kB1323.3 kB105.9 kB110.8 kB
Python164491083.4 kB1396.7 kB140.6 kB146.7 kB
diff --git a/dev/index.html b/dev/index.html index c5f041c..76e65b5 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · DocInventories.jl

DocInventories.jl

Github v0.3.0+dev

DocInventories.jl is a package for reading and writing inventory files such as the objects.inv file used by InterSphinx and DocumenterInterLinks.jl. It is designed to be used in the REPL, to interactively explore inventory files, and as a backend for DocumenterInterLinks.

Installation

As usual, that package can be installed via

] add DocInventories

in the Julia REPL, or by adding

DocInventories = "43dc2714-ed3b-44b5-b226-857eda1aa7de"

to the relevant Project.toml file.

Contents

+Home · DocInventories.jl

DocInventories.jl

Github v0.3.1

DocInventories.jl is a package for reading and writing inventory files such as the objects.inv file used by InterSphinx and DocumenterInterLinks.jl. It is designed to be used in the REPL, to interactively explore inventory files, and as a backend for DocumenterInterLinks.

Installation

As usual, that package can be installed via

] add DocInventories

in the Julia REPL, or by adding

DocInventories = "43dc2714-ed3b-44b5-b226-857eda1aa7de"

to the relevant Project.toml file.

Contents

diff --git a/dev/usage/index.html b/dev/usage/index.html index cc62be1..38efeba 100644 --- a/dev/usage/index.html +++ b/dev/usage/index.html @@ -73,4 +73,4 @@ InventoryItem(":std:label:`REPL-based-workflow`" => "manual/workflow-tips/#\$", dispname="REPL-based workflow") InventoryItem(":std:label:`Revise-based-workflows`" => "manual/workflow-tips/#\$", dispname="Revise-based workflows") InventoryItem(":std:label:`man-workflow-tips`" => "manual/workflow-tips/#\$", dispname="Workflow Tips") - InventoryItem(":std:doc:`manual/workflow-tips`" => "manual/workflow-tips/", dispname="Workflow Tips")

The search results will be sorted taking into account the priority field of the items.

Saving Inventories to File

An inventory can be written to file using the DocInventories.save function. For example, to write the inventory in TOML Format, use

DocInventories.save("$(tempname()).toml", inventory)

The MIME type is derived from the extension of the file name, according to the mapping in DocInventories.MIME_TYPES. The MIME-type can also be passed explicitly to save, independent of the file name:

DocInventories.save(tempname(), inventory; mime="application/toml")

It is also possible to write with compression by appending a .gz file extension:

DocInventories.save("$(tempname()).toml.gz", inventory)

See Inventory File Formats for a description of all available output formats.

+ InventoryItem(":std:doc:`manual/workflow-tips`" => "manual/workflow-tips/", dispname="Workflow Tips")

The search results will be sorted taking into account the priority field of the items.

Saving Inventories to File

An inventory can be written to file using the DocInventories.save function. For example, to write the inventory in TOML Format, use

DocInventories.save("$(tempname()).toml", inventory)

The MIME type is derived from the extension of the file name, according to the mapping in DocInventories.MIME_TYPES. The MIME-type can also be passed explicitly to save, independent of the file name:

DocInventories.save(tempname(), inventory; mime="application/toml")

It is also possible to write with compression by appending a .gz file extension:

DocInventories.save("$(tempname()).toml.gz", inventory)

See Inventory File Formats for a description of all available output formats.