Skip to content

Conversation

@kattni
Copy link
Contributor

@kattni kattni commented Aug 24, 2025

Progress tracking

There are four major pieces left to this before it becomes individual fixes:

  1. COMPLETE - Making sure the Markdown content is valid, links work, it matches the existing content.
  2. COMPLETE - Verifying that the methods/attributes/etc that are displayed in the Reference section match the existing content.
  3. COMPLETE - Converting the docstrings in the source code from rST to Markdown.
  4. COMPLETE - Verifying the docstring content rendered in the documentation.
4: Completed

Verify diff and that all links are working properly.

  • core/src/toga/init.py
  • core/src/toga/app.py
  • core/src/toga/colors.py
  • core/src/toga/command.py
  • core/src/toga/constants/init.py
  • core/src/toga/dialogs.py
  • core/src/toga/documents.py
  • core/src/toga/fonts.py
  • core/src/toga/handlers.py
  • core/src/toga/hardware/init.py
  • core/src/toga/hardware/camera.py
  • core/src/toga/hardware/location.py
  • core/src/toga/icons.py
  • core/src/toga/images.py
  • core/src/toga/keys.py
  • core/src/toga/paths.py
  • core/src/toga/platform.py
  • core/src/toga/plugins/init.py
  • core/src/toga/plugins/image_formats.py
  • core/src/toga/resources/init.py
  • core/src/toga/screens.py
  • core/src/toga/sources/init.py
  • core/src/toga/sources/accessors.py
  • core/src/toga/sources/base.py
  • core/src/toga/sources/list_source.py
  • core/src/toga/sources/tree_source.py
  • core/src/toga/sources/value_source.py
  • core/src/toga/statusicons.py
  • core/src/toga/style/init.py
  • core/src/toga/style/applicator.py
  • core/src/toga/style/mixin.py
  • core/src/toga/style/pack.py
  • core/src/toga/types.py
  • core/src/toga/validators.py
  • core/src/toga/widgets/init.py
  • core/src/toga/widgets/activityindicator.py
  • core/src/toga/widgets/base.py
  • core/src/toga/widgets/box.py
  • core/src/toga/widgets/button.py
  • core/src/toga/widgets/canvas/init.py
  • core/src/toga/widgets/canvas/canvas.py
  • core/src/toga/widgets/canvas/context.py
  • core/src/toga/widgets/canvas/drawingobject.py
  • core/src/toga/widgets/canvas/geometry.py
  • core/src/toga/widgets/dateinput.py
  • core/src/toga/widgets/detailedlist.py
  • core/src/toga/widgets/divider.py
  • core/src/toga/widgets/imageview.py
  • core/src/toga/widgets/label.py
  • core/src/toga/widgets/mapview.py
  • core/src/toga/widgets/multilinetextinput.py
  • core/src/toga/widgets/numberinput.py
  • core/src/toga/widgets/optioncontainer.py
  • core/src/toga/widgets/passwordinput.py
  • core/src/toga/widgets/progressbar.py
  • core/src/toga/widgets/scrollcontainer.py
  • core/src/toga/widgets/selection.py
  • core/src/toga/widgets/slider.py
  • core/src/toga/widgets/splitcontainer.py
  • core/src/toga/widgets/switch.py
  • core/src/toga/widgets/table.py
  • core/src/toga/widgets/textinput.py
  • core/src/toga/widgets/timeinput.py
  • core/src/toga/widgets/tree.py
  • core/src/toga/widgets/webview.py
  • core/src/toga/window.py
1 and 2: Completed

This is the list of Markdown files in the docs/en. I am currently going through the Markdown content in each file to verify links and content are accurate, and, when applicable, to verify that class documentation is displaying correctly.

  • about/community.md
  • about/faq.md
  • about/philosophy.md
  • about/releases.md
  • about/roadmap.md
  • about/success.md
  • how-to/contribute/code.md
  • how-to/contribute/docs.md
  • how-to/internal/release.md
  • index.md
  • reference/api/app.md
  • reference/api/constants.md
  • reference/api/containers/box.md
  • reference/api/containers/optioncontainer.md
  • reference/api/containers/scrollcontainer.md
  • reference/api/containers/splitcontainer.md
  • reference/api/documentwindow.md
  • reference/api/hardware/camera.md
  • reference/api/hardware/location.md
  • reference/api/hardware/screens.md
  • reference/api/index.md
  • reference/api/keys.md
  • reference/api/mainwindow.md
  • reference/api/resources/app_paths.md
  • reference/api/resources/command.md
  • reference/api/resources/dialogs.md
  • reference/api/resources/document.md
  • reference/api/resources/fonts.md
  • reference/api/resources/icons.md
  • reference/api/resources/images.md
  • reference/api/resources/sources/list_source.md
  • reference/api/resources/sources/source.md
  • reference/api/resources/sources/tree_source.md
  • reference/api/resources/sources/value_source.md
  • reference/api/resources/statusicons.md
  • reference/api/resources/validators.md
  • reference/api/types.md
  • reference/api/widgets/activityindicator.md
  • reference/api/widgets/button.md
  • reference/api/widgets/canvas.md
  • reference/api/widgets/dateinput.md
  • reference/api/widgets/detailedlist.md
  • reference/api/widgets/divider.md
  • reference/api/widgets/imageview.md
  • reference/api/widgets/label.md
  • reference/api/widgets/mapview.md
  • reference/api/widgets/multilinetextinput.md
  • reference/api/widgets/numberinput.md
  • reference/api/widgets/passwordinput.md
  • reference/api/widgets/progressbar.md
  • reference/api/widgets/selection.md
  • reference/api/widgets/slider.md
  • reference/api/widgets/switch.md
  • reference/api/widgets/table-accessors.md
  • reference/api/widgets/table-values.md
  • reference/api/widgets/table.md
  • reference/api/widgets/textinput.md
  • reference/api/widgets/timeinput.md
  • reference/api/widgets/tree.md
  • reference/api/widgets/webview.md
  • reference/api/widgets/widget.md
  • reference/api/window.md
  • reference/internals/architecture.md
  • reference/platforms/android.md
  • reference/platforms/index.md
  • reference/platforms/iOS.md
  • reference/platforms/linux.md
  • reference/platforms/macOS.md
  • reference/platforms/terminal.md
  • reference/platforms/testing.md
  • reference/platforms/unix-prerequisites.md
  • reference/platforms/web.md
  • reference/platforms/windows.md
  • reference/plugins/image_formats.md
  • reference/style/pack.md
  • reference/widgets_by_platform.md
  • SUMMARY.md
  • topics/api-design.md
  • topics/data-sources.md
  • topics/debugging.md
  • topics/file-management.md
  • topics/layout.md
  • tutorial/get-started.md
  • tutorial/index.md
  • tutorial/tutorial-0.md
  • tutorial/tutorial-1.md
  • tutorial/tutorial-2.md
  • tutorial/tutorial-3.md
  • tutorial/tutorial-4.md

Original proof-of-concept content

Original proof-of-concept PR content

This is a proof of concept for switching Toga to Markdown and MkDocs. As requested, I have fully updated a few of the more complex documentation pages and the docstrings for the associated class documentation, and outlined the changes to look for below. Consider this a guided tour of what to expect from MkDocs as a developer and documentation author.

config.yml

This is the base configuration file that is inherited by the mkdocs.en.yml file. It is separated for consistency, and to enable a straightforward path to translations. I want to quickly explain what is happening in the potentially-less-obvious parts of this file:

  • extra: - Anything in this is made available to the Macros plugin, and can be used as a Jinja variable. The Material theme reads it as well for various things, including, in this case, the social media links that are rendered in the footer. I am using the project_name to generate the GitHub URLs in the sidebar. The last four keys are strings that when included in the Markdown as {{ string_content }}, will automatically be replaced by the value paired with the key string.
    • NOTE: The reason I have not used fully_supported and partly_supported in the CSV file is that the tables themselves are rendered by the Jinja run on initial Markdown render, and therefore cannot recognise Jinja directives within the table, as the table content is not available until after the Jinja is expanded.
  • theme: - We are using the MkDocs Material theme. The enabled content, toc, and navigation features are set to create a similar navigation experience to the current documentation. The search features include suggested search term completion, highlighting your search term on the page you navigate to from the search modal, and your search generating an actual URL for sharing purposes.
    • theme: custom_dir - This is the location of the theme overrides, which are provided by BeeWare Docs Tools on build and live-serve of the site.
    • theme: palette - This provides light mode, dark mode, and automatic mode which follows the system preference, including automatically changing depending on the time of day without needing to refresh the site.
  • markdown_extensions: - PyMdown Extensions (pymdownx) is a collection of extensions for Python Markdown. We are using several of them. Anything not beginning with pymdownx is standalone. Most extensions are pretty self-explanatory. Less obvious are:
    • pymdownx:
      • caret - This provides the ability to use ^ to superscript text. It is used for the beta and no-support symbols, but can be used for anything.
      • snippets - This provides the syntax for including external content, either from a local file or from a URL. I have noted two files below that show the syntax in action for including a local file. Snippets has the option to provide delimiters in a file, and syntax to limit the content included to what is contained between the delimiters. It also allows you to include specific line numbers or a range of line numbers; however, I don't recommend it as, if the file changes, you will have to remember to update your include content. The delimiters are a convenient way to avoid that problem.
        • NOTE: The base_path is a provided directory that the include path can begin with. In the event that you wish to include content from another directory, you would add it here.
    • attr_list - This provides syntax for custom anchors on headers and text. The header format is { id="anchor-name" }, included after the header with a space between the end of the header and the opening curly bracket. This can be done on any header to provide any custom name. The arbitrary text anchor format is [](){ id="anchor_name" } on a blank line above the intended paragraph, with whitespace before and after. This means if you link to that anchor, it will navigate to that paragraph of text.
  • plugins: - Most of these are also self-explanatory. Worth noting are:
    • autorefs - This is the plugin that handles the class documentation linking, and the direct anchor linking. As there are several iterations of the link syntax; they are all exhibited in the documentation updates. The basics of linking class documentation is [displayed text][class.Module], or if you wish to link to the full class name, [class.Module][]. The basics of anchor linking is [displayed text][anchor-name] or if you wish to display the anchor name, [anchor-name][]. There are more details and examples below.
    • literate-nav - I tried several options for controlling how the left sidebar navigation is displayed, and this was the only option that allowed me to replicate the current documentation layout. It requires explicitly writing out the link layout in the SUMMARY.md file that lives with the documentation. Once this file is present, if an intended sidebar link is not included in the file, it will not be displayed. If a file or directory exists that will be excluded due to this file, the build and live-serve will fail on a warning. There is work required initially to get this set up, but it's relatively straightforward to keep it updated. Not everything needs to be included, only link structures that you want to specify, or links that have display names that don't match the filename or directory name. Otherwise, links are alphabetical. If you view the linked file, you'll see what was required for Toga to look similar to how it looks currently.
    • macros - This provides a lot of Jinja options including automatic replacement of key:value pairs from the extra keyword above, and basic Jinja including conditionals and loops. It's necessary for the CSV tables generated by table_reader, and provides options for a lot of other things.
    • table-reader - This generates the tables from the CSV file for the widgets. It uses the macros plugin, and Pandas. Syntax is identified below.
    • mkdocstrings - mkdocstrings is the MkDocs sphinx-autodoc equivalent. It generates the class documentation from the source code. Configuration details are below.

Documentation features by page

  • / (docs/en/index.md)
    • Centered images: There is syntax for aligning images left and right, but center apparently isn't a thing, so it's not supported by the theme. The workaround is to follow the image with an empty caption. Note the extra whitespace; it is necessary for it to render properly.
    • Image width notation: There is syntax for setting the image width shown here, that will also work for left and right align if desired.
    • Custom header anchors: the headers that are linked using a reference other than the word-for-word anchor generated by Markdown have custom anchors attached to them.
    • Linking to directory indexes: when linking to a directory containing an index.md file, you do not need to include /index.md on the end of the link target.
  • Reference > API > Resources > Image (docs/en/reference/api/resources/images.md and (images.py)
    • CSV-generated table: CSV generated "Availability" table rendered.
    • CSV-generated table syntax: Shows the Markdown syntax for the rendered "Availability" CSV-generated tables (starts with {{ pd_read_csv).
    • Linking text to an existing anchor: Key in the Availability table title shows the syntax for linking text to an existing anchor. This can be either a custom anchor you provided, or the anchor that is automatically generated by Markdown (e.g. the anchor for this page would be image).
    • Linking to class documentation: The first admonition shows several examples of linking text to class documentation. This is how you recreate :class:~module.Class links. So :class:~toga.Image would be [Image][toga.Image]. You must supply the backticks for it to be rendered as inline code.
    • Linking custom text to class documentation: The sentence after the admonition shows linking arbitrary text to class documentation. The syntax is [text][module.Class]. In this case, it links the text to ImageContentT, with [wide range of sources][toga.images.ImageContentT].
    • Custom header anchor without a header: under "Notes", the syntax for creating a custom anchor on a paragraph without a heading is included. The syntax is [](){ id="known-image-formats" }. See ImageContentT for an example of linking to these anchors.
    • TypeAlias linking: ImageContentT is displayed in the reference documentation, and is linked both manually in links, and automatically in the TYPE: element. The docstring is pulled from the original images.rst file, where the info is currently displayed.
      • Note: Due to what ImageContentT is in the code, it doesn't see the = PathLikeT | BytesLikeT | ImageLikeT as a "signature", and therefore doesn't allow for hiding it. This would likely be the case with any linked typealias. There are potential workarounds I'm sure; however, I did not begin looking into this yet.
    • Pillow documentation external linking: See as_format for a link to PIL.Image.Image. The syntax is [PIL.Image.Image][].
  • Reference > API > Widgets > ImageView (docs/en/reference/api/widgets/imageview.md and imageview.py)
    • Macros plugin replacement feature: See the "no support" symbol on the tabbed support table.
    • Linking to the full class name: The Notes section shows two examples of the notation for linking to a class when you want to display the full name. The syntax is [module.Class][]. So, :class:toga.Button would be [toga.Button][]. Backticks required for inline code rendering.
    • TypeAlias linking: ImageContentT is displayed in the reference documentation, and is linked both manually in links, and automatically in the TYPE: element.
    • Signature option disabled: The separate_signature and show_signature options are disabled on the class documentation, to show what it looks like without them.
      • NOTE: It turns out it's not possible to have a text-header of, for example, "toga.ImageView", without having the code-rendered signature displayed below it. It is either toga.ImageView in code format, or it is a text header "toga.ImageView" with a codeblock below it including either ImageView, if show_signature is disabled, or ImageView(image=None, id=None, style=None, **kwargs), if show_signature is enabled.
    • Python documentation external linking: See image for an example of linking to None in the Python docs. The syntax is [None][].
  • Reference > API > Widgets > Canvas (docs/en/reference/api/widgets/canvas.md and /canvas/*.py)
    • Linking to a method with the short name: The third paragraph in the "Usage" shows the autoref equivalent of :meth:~Canvas.redraw, which is [Canvas.redraw][toga.Canvas.redraw]. Backticks required for inline code rendering.
    • Include/exclude members from class calls: The toga.Canvas mkdocstrings call shows what is necessary to include specific class members. To look at it another way, to exclude specific class members, you must list the members you want to include.
      • NOTE: :yields: is not currently supported by mkdocstrings (a feature request is in and has been acknowledged). The workaround is to use :return: and specific wording to the effect of "Yields the new...."
    • Method linking: See DrawingObject for two examples of the :meth: equivalent. To render :meth:~toga.widgets.canvas.Context.append is [append()][toga.widgets.canvas.Context.append].
  • Reference > Toga APIs by platform (docs/en/reference/widgets_by_platform.md and widgets_by_platform.csv)
    • CSV-generated widget tables: See this version of these tables rendered.
      • NOTE: "Core Components" links have been updated; the others have not.
    • CSV-generated table syntax: See the Markdown syntax for this version of tables.
  • Reference > API > MainWindow (docs/en/reference/api/mainwindow.md)
    • Macros plugin replacement feature: See the "beta support" symbol on the tabbed support table.
  • Reference > API > Widgets > Tree (docs/en/reference/api/widgets/tree.md)
    • Snippets local file include syntax: This file contains two examples of including content from a local file. The syntax is -8<- "reference/api/widgets/table-accessors.md". The -8<- is either on the same line as the file, or if you want to include multiple files, you can put it on a line of its own, the files below it, each on their own line, and another instance of -8<- below that. Including a file from a URL is the same syntax; simply replace the filename with the URL.

mkdocstrings

The available configuration options can be found here. There are many. They are separated into five categories: General, Headings, Members, Docstrings, and Signatures. I recommend reviewing them all, as there may be things available here that you feel are better than what the current documentation had to offer, which is why I am including the link here; they provide a good explanation of what each option does and show examples for many of them.

I have enabled several based on the current documentation, which I have outlined below. They are separated into sections based on whether they are required, highly recommended, or you need to take a look at the link above and the rendered documentation as linked below and make a decision on how you want it to look.

Currently set mkdocstrings configuration options:

Required:

  • docstring_style: sphinx - Parses docstrings from Sphinx formatting; the :param etc. formatting, not parsing rST links.
  • show_root_heading: true - Shows the class name and/or signature, based on other options. This is absolutely necessary, otherwise no info on the class name is rendered.

Highly recommended as-is:

  • docstring_section_style: spacy - The layout of the docstring information. The other options are table and list. The spacy option looks the best to me; it shows the info with the least amount of superfluous information or whitespace. Recommend keeping this as-is.
  • merge_init_into_class: true - If disabled, init is displayed separately. Highly recommend this setting.
  • show_source: false - Enabled by default; shows the source code for the class below the signature if enabled; I don't recommend enabling it; it is entirely too busy.

Your opinion needed:

  • members_order: alphabetical - Shows class members alphabetically; the other option is source which is ordered based on the source code.
  • allow_inspection: false - True includes dunder methods; this can be enabled on individual class entries if you want them included.
  • annotations_path: brief - Determines the verbosity of the annotations path. This is the recommended setting. Other options are source and full.
  • Not included but worth noting: show_labels: which defaults to true. This is what handles the member labels like instance-attribute and property writable. I wanted to point out that this is configurable, though I didn't include it in the current configuration.

Signature settings - your opinion needed:

Context: the "signature" is the code-rendered display of a class/method/attribute/function name. It can be shown below a text-rendered version of the name, or it can be the only version of the name displayed. This is entirely a personal preference option.

  • separate_signature: true - Shows the ClassName(args) separately from header name. There are examples of it enabled and disabled in this PR.
  • show_signature: true - Displays () or (args) along with the function name in the signature. This should for sure be disabled if you choose to globally disable the separate_signature option.
  • show_signature_annotations: false - Disabling this removes annotations from the signature. Highly recommend this setting regardless of whether you opt for a separately displayed signature; enabled it's too much.
  • line_length: 80 - Forces longer signatures to be stacked, instead of overflowing their space and triggering a scrollbar. Requires Black. If you opt to hide signatures, this can be removed, though I would consider leaving it in to handle signatures if they are enabled on individual class calls.

Included only for the visual:

  • show_symbol_type_toc: true - Adds the colorful symbols next to the function/class names in the sidebar table of contents. This is what they added on place of rendering function() (with parens) in the sidebar list. I have a feature request in for making it configurable to include the parens, but there hasn't been any movement on it. It seems like a lot to me, and also doesn't mean much to me in terms of whether it adds any meaningful information based on my level of knowledge. I enabled it so you could see it, but I am not sure if it's worth keeping.

Linting

There are two tools being used for linting, beyond what MkDocs, Macros, and autorefs are doing automatically on build.

  • markdown-checker is being used to verify external URLs are still valid.
  • pyspelling is the spellchecker.
    • NOTE: It is much stricter than the existing spellchecker. It is case-sensitive, for example, which may be an improvement for Reasons. Regardless, it will mean a longer spelling exclusion list. Once it's sorted out initially, it will be a reasonable task to keep it up-to-date.
    • NOTE: I have disabled pyspelling for the purposes of this demonstration, as this is meant only to be a proof of concept.

Potential blockers and nice-to-haves identified before starting this process

There were a few potential blockers identified ahead of this process. I want to document them and the solutions here.

  • Is there an equivalent to sphinx.autodoc?
    • Yes, mkdocstrings. I linked to the configuration options above.
  • How does cross-referencing work?
    • This is handled by autorefs, and the syntax for various types of links are outlined above.
  • Will it handle a table of contents?
    • Yes, this is handled by the theme. Ordering is handled by the literate-nav plugin, as outlined above.
  • What is the strategy for translations, and migrating the existing translations, on the Tutorial?
    • This is handled in beeware-docs-tools, and the existing translations have been successfully migrated.
  • What is the build time for MkDocs vs Sphinx?
    • In my experience, once error-free, MkDocs is noticeably faster. Watching changes in the source code directories for the rebuild-trigger does not slow it down in any appreciable way, which it is my understanding was an issue with Sphinx. This build is currently loaded with errors, so its build-time is not a good example of the actual build speed.

There were a few nice-to-haves as well that are possible with MkDocs.

  • Better handling of type annotations.
  • Default linking to TypeAliases.
  • Ability to include external content via URL, i.e. from a separate repo. This will enable us to host the common parts of the contribution guides in one place..

Noteable CSS issues:

  • The Availability tables are wide enough to trigger a scrollbar.
  • The APIs by Platform tables currently have every column the same width, and are also too wide.

Miscellaneous:

  • There are a number of TODOs in various places, including comments in the Markdown to update the alt text on images. This is something I think should be done, as the alt text provided in the existing documentation is the path to the file. They are specifically HTML tagged comments so they will not render in the Markdown, and therefore can be dealt with at any time in the future. It may be worth a future good first issue.
  • Switched pyproject.toml to dependency groups. This meant moving the dependencies to the pyproject.toml in the root of the project, for tox to be able to use them.
    • NOTE: I have left the core/pyproject.toml intact, because I don't entirely understand how Toga works in this regard, and I didn't want to break something else. I imagine the dependencies should be removed from core/pyproject.toml, but I will wait on that until it is clarified.

TODO:

Among other things, the following changes are necessary before finalising:

  • Check TODOs in docs and code, and resolve necessary tasks.
  • Remove --build-with-errors from tox.ini: docs live and en.
  • Reenable pyspelling in tox.ini and resolve errors.
  • Add rumdl to pre-commit, resolve errors. - Tool is not ready at this time to be added to pre-commit.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@kattni kattni marked this pull request as draft August 24, 2025 05:51
@kattni
Copy link
Contributor Author

kattni commented Aug 24, 2025

Read the Docs says that the required pip version for dependency groups is the default version, however that is not the case in our build. I believe this may be due to the RTD build os version being behind. I forced a python -m pip install --upgrade pip in .readthedocs.yaml, which works for now, but we may want to consider upgrading the build environment, and potentially the Python version to match the configuration they show in the example explaining using dependency groups.

@kattni
Copy link
Contributor Author

kattni commented Aug 24, 2025

@freakboy3742 @mhsmith The preview is available for you to take a look at. I have outlined the details above, with links to the relevant documentation pages and source code files. I'm happy to answer any questions you may have.

@freakboy3742
Copy link
Member

Initial impressions: this looks slick. Even with the TODOs and minor issues, this is looking really good.

Three things that stood out on my initial review:

  1. The Toga version number isn't correct. Not sure what is going on there, since that's behavior inherited from docs-tools.
  2. I have quickly developed a love-hate relationship with the "next/prev" block at the bottom of the page. It takes up a lot of screen space - which isn't a problem when the page is long (like the Canvas API page), because it only scrolls into view when you're at the bottom of the page. But when the page is short (e.g., the "style" index page, it's so big that it makes the side navigation almost unusable.
  3. As I understand it, MkDocs will give us an opportunity to do some cleanup on "index pages that need to exist because of Sphinx". For example, the style page - does that page need to exist, or could we have the sidebar index be expandable, providing a link directly to the Pack page. You could possibly even make this argument for top-level index pages like Reference - is that top level index really adding anything? Removing those index pages wasn't really an option with Sphinx - but if we've got "dead" pages of index content, and we can clean them up, that seems like a win.

(2) and (3) are somewhat related, because the issues with (2) are more acute on the (3)-style index pages. It's also related to the scrolling issue flagged in beeware/beeware-docs-tools#10 - and made worse by the fact that once there's a header, logo, and footer bar, the amount of real-estate available to display the actual index is fairly constrained.

types defined by installed :doc:`image format plugins
</reference/plugins/image_formats>`.
:param format: Format to provide. Defaults to [`Image`][toga.images.Image]; also
supports [PIL.Image.Image][] if Pillow is installed, as well as any image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
supports [PIL.Image.Image][] if Pillow is installed, as well as any image
supports [`PIL.Image.Image`][] if Pillow is installed, as well as any image

Comment on lines 53 to 55
Every context drawing method creates a ``DrawingObject``, adds it to the context,
and returns it. Each argument passed to the method becomes a property of the
``DrawingObject``, which can be modified as shown in the `Usage`_ section.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the "usage" reference in this suggestion.

Suggested change
Every context drawing method creates a ``DrawingObject``, adds it to the context,
and returns it. Each argument passed to the method becomes a property of the
``DrawingObject``, which can be modified as shown in the `Usage`_ section.
Every context drawing method creates a `DrawingObject`, adds it to the context,
and returns it. Each argument passed to the method becomes a property of the
`DrawingObject`, which can be modified as shown in the [Usage][] section.

types defined by installed :doc:`image format plugins
</reference/plugins/image_formats>`
:param format: Format to provide. Defaults to [`Image`][toga.images.Image]; also
supports [PIL.Image.Image][] if Pillow is installed, as well as any image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
supports [PIL.Image.Image][] if Pillow is installed, as well as any image
supports [`PIL.Image.Image`][] if Pillow is installed, as well as any image

@johnzhou721

This comment was marked as resolved.

@freakboy3742

This comment was marked as resolved.

@mhsmith
Copy link
Member

mhsmith commented Sep 5, 2025

Thanks for the thorough notes, this looks really good. Just a few comments:

  • attr_list - This provides syntax for custom anchors on headers and text. The header format is { id="anchor-name" }

According to the docs, this can also be written as { #anchor-name }, which is a bit easier to read and write.

The arbitrary text anchor format is [](){ id="anchor_name" } on a blank line above the intended paragraph, with whitespace before and after.

This also can be done using the # syntax. And it looks like it also supports putting the { ... } block below the paragraph with no whitespace in between. However, the link destination would still be the top of the paragraph, so that would be confusing.

Note the extra whitespace; it is necessary for it to render properly.

Do you mean the extra space above and below the image? Will this affect all images in the documentation, and why is it necessary?

The first admonition

This doesn't follow the !!! syntax documented here, but something different starting with ///. Why is this?

A similar syntax is used for tabs, and it makes the docs source code much longer and much harder to read than the RST equivalent.

To render :meth:~toga.widgets.canvas.Context.append is [append()][toga.widgets.canvas.Context.append].

mkdocstrings has relative_crossrefs and scoped_crossrefs options which would allow this to be abbreviated as in Sphinx. But they're currently in a sponsors-only version, so even if we did sponsor them, I'm not sure if we could use that in a public workflow.

For example, the style page - does that page need to exist, or could we have the sidebar index be expandable, providing a link directly to the Pack page.

It looks like this has now been resolved for the Style page, but not everywhere else, e.g. clicking Resources still takes you to an empty page rather than expanding the sidebar TOC.

@johnzhou721
Copy link
Contributor

To render :meth:~toga.widgets.canvas.Context.append is [append()][toga.widgets.canvas.Context.append].

mkdocstrings has relative_crossrefs and scoped_crossrefs options which would allow this to be abbreviated as in Sphinx. But they're currently in a sponsors-only version, so even if we did sponsor them, I'm not sure if we could use that in a public workflow.

So y'all would prefer relative cross reference if it's possible?

Sorry for commenting on a proof-of-concept but on https://mkdocstrings.github.io/insiders/ there's this wording

Please don't distribute the source code of Insiders. You may freely use it for public, private or commercial projects, privately fork or mirror it, but please don't make the source code public, as it would counteract the sponsorware strategy.

So if we sponsored them we could publicly use it.

I'd like to also bring https://analog-garage.github.io/mkdocstrings-python-xref/latest/ to attention for relative references. It has some nice but weird syntax like (c) for current class and (p) for current package and you can also do like .property or ..attribute like normally.

@kattni kattni changed the title WIP: Proof of concept for switching to MkDocs. Move Toga to MkDocs and Markdown Oct 6, 2025
@kattni kattni marked this pull request as ready for review October 6, 2025 06:18
@kattni
Copy link
Contributor Author

kattni commented Oct 6, 2025

@freakboy3742 Here's the list that needs docstring content, and the files they are in.

ImageT (images.py) (verify - added from images.md)
ExternalImageT (images.py)
OptionContainerContentT (optioncontainer.py)
SplitContainerContentT (splitcontainer.py) (verify - added from splitcontainer.md)
StyleT (base.py)
PositionT (types.py)
SizeT (types.py)
DialogResultT (dialogs.py)
SourceT (detailedlist.py)
NumberInputT (numberinput.py)
SourceT (selection.py)
SourceT (table.py)
SourceT (tree.py)

Search for TODO: Update docstring content.

@freakboy3742
Copy link
Member

@freakboy3742 Here's the list that needs docstring content, and the files they are in.

I've pushed an update with docstrings for all of these except DialogResultT; that's a bit of a weird one that's more of a side effect of how the class using it needs to be defined - it's not actually communicating anything meaningful. I've removed the reference from dialogs.md.

I've also done a bit of a light re-org of the types around table/tree/selection/detailedList - they were all referencing a locally defined SourceT, which wasn't wrong, but was missing some commonalities.

@mhsmith
Copy link
Member

mhsmith commented Oct 6, 2025

@freakboy3742: As requested, I've had another look over this, and I'm OK for it to be merged to avoid any more conflicts.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor issues flagged inline (which you've already addressed); and I'm sure we'll find some minor issues to shake out - but we can deal with those as follow up PRs. This is a truly spectacular effort - Thank you.

# Docs are always built on Python 3.12. See also the tox config and contribution docs.
python: "3.12"
# Docs are always built on Python 3.12. See also the tox config.
python: "3.13"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
python: "3.13"
python: "3.12"

pyproject.toml Outdated
@@ -104,7 +104,35 @@ type = [
{ directory = "misc", name = "Misc", showcontent = false },
]

[tool.setuptools_scm]
# [tool.setuptools_scm]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems odd - either we don't need setuptools_scm config at the root level, or this has been commented out in error.

@freakboy3742 freakboy3742 merged commit e427657 into beeware:main Oct 6, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants