# sphobjinv.cli.suggest

`sphobjinv` module for CLI suggest functionality.

`sphobjinv` is a toolkit for manipulation and inspection of Sphinx objects.inv files.

Author

  Brian Skinn (brian.skinn@gmail.com)

File Created

  20 Oct 2022

Copyright

  (c) Brian Skinn 2016-2024

Source Repository

  https://github.com/bskinn/sphobjinv

Documentation

  https://sphobjinv.readthedocs.io/en/stable

License

  Code: MIT License

  Docs & Docstrings: CC BY 4.0 International License

  See LICENSE.txt for full license terms.

Members

confirm_print_if_long_list(params, results)

  Check if the results list is too long and query user if to proceed.

  Skip the check if `--all` has been passed.

  Also skip the check if receiving data from `stdin`, as a stream interaction here fouls the data flow…I forget exactly how.

do_suggest(inv, params)

  Perform the suggest call and output the results.

  Results are printed one per line.

  If neither `INDEX` nor `SCORE` is specified, the results are output without a header. If either or both are specified, the results are output in a lightweight tabular format.

  If the number of results exceeds `SUGGEST_CONFIRM_LENGTH`, the user will be queried whether to display all of the returned results unless `ALL` is specified.

  No `QUIET` option is available here, since a silent mode for suggestion output is nonsensical.

  Parameters:

    - inv – `Inventory` – Inventory object to be output in the format indicated by `MODE`.

    - params – `dict` – Parameters/values mapping from the active subparser

extract_objectsinv_url_base(objectsinv_url)

  Infer a base URL for the provided `objects.inv` inventory URL.

  If this function is a no-op, then the resulting base is NOT RELIABLE, because the URL did not end with `/objects.inv`.

  If this function does make a change, then the resulting base is RELATIVELY RELIABLE, since the only change that should occur is stripping of a `/objects.inv` suffix, which strongly implies but does not guarantee that the URL came from a Sphinx docset in the standard multi-page HTML layout.

  Parameters:

    objectsinv_url – `str` – URL from which to attempt docset base inference

  Returns:

    trimmed – `str` – URL after attempt to trim a trailing `/objects.inv`

generate_index_lines(results, index_width, rst_width)

  Yield lines to print the table with indices.

generate_names_only_lines(results)

  Yield lines to print containing just the object search results.

generate_score_index_lines(results, score_width, index_width, rst_width)

  Yield lines to print the table with scores & indices.

generate_score_lines(results, score_width, rst_width)

  Yield lines to print the table with scores.

print_divider(params)

  Print a visual divider to break up sections of the CLI output.

print_results_table(with_index, with_score, results, params)

  Prepare and print the table of suggest search results.

print_stderr_inferred_mapping(params)

  Print as good of an intersphinx_mapping entry as can be determined.

print_stderr_result_count(params, results)

  Report the count of found objects from the suggest search.