Skip to content

Allow documentation extensions to omit module name when there's only one module #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
d-ronnqvist opened this issue Mar 23, 2023 · 3 comments · Fixed by #565 or #578
Closed

Allow documentation extensions to omit module name when there's only one module #516

d-ronnqvist opened this issue Mar 23, 2023 · 3 comments · Fixed by #565 or #578
Assignees
Labels
enhancement Improvements or enhancements to existing functionality link resolution About DocC's link resolution system

Comments

@d-ronnqvist
Copy link
Contributor

Feature Name

Module-level resolution for documentation extensions

Description

Documentation extension files are markdown files that extend/continue the in-source documentation of symbols. To associate the documentation extension file with the symbol, the documentation extension file starts with a heading with an absolute symbol link to the symbol.

Because documentation catalogs are almost always associated with a single module, this means that every documentation extension repeats the same module name in its heading. When the documentation build covers a single module, it would be nice to be able to omit the module name in these documentation extension headings.

However, it's still important that modules that also have a top-level symbol with the same name as the module can create documentation extension files for both the module itself and the top-level symbol.

There are two main possibilities that I can see for handling this ambiguity:

  • Require an absolute path for the symbol with the same name as the module
  • Require that the ambiguous module reference starts with a leading slash.

rdar://76252171

Motivation

When using DocC to document a module, being able to omit the module name in the documentation extension headings is a small improvement to the user experience of writing documentation extensions. For some developers who are new to DocC it may be more natural to start with the name of the symbol, not the name of the module that contains the symbol.

Importance

This is a small and fairly low priority change.

Alternatives Considered

The main alternatives to consider is how to handle the new possible ambiguity if a module has a top-level symbol with the same name as the module. For example; the Something module would have a Something class or struct.

Today, the absolute links to these would be Something and Something/Something.

A simple solution to this problem is to not allow the relative link to the symbol if it has the same name as the module. In other words; the developer would still need to write Something/Something to reference the symbol but could write SomethingElse for another symbol in the same module. This has the benefit that it is fully backwards compatible.

An alternative solution would be to require a leading slash for the module name reference if it collides with a symbol. This is consistent with how a leading slash result in an absolute symbol link lookup in other places, but it's a rarely used feature. The biggest benefit for this is that the link Something would change from referring to the module to referring to the top-level symbol instead.

@d-ronnqvist d-ronnqvist added enhancement Improvements or enhancements to existing functionality good first issue Good for newcomers labels Mar 23, 2023
@d-ronnqvist
Copy link
Contributor Author

I'm tagging this as a "good first issue" even though it's more of a good second or third issue. This mainly involved changes to link resolution and some new diagnostics. I'm happy to go into more detail if anyone is interested in this issue.

@d-ronnqvist d-ronnqvist self-assigned this Apr 23, 2023
@d-ronnqvist d-ronnqvist added link resolution About DocC's link resolution system and removed good first issue Good for newcomers labels Apr 23, 2023
@d-ronnqvist
Copy link
Contributor Author

the work I’m doing for #561 will also resolve this.

@d-ronnqvist
Copy link
Contributor Author

This change caused some regression when a module and a top-level symbol had the same name. I make a targeted revert and work to reenable this again once those issues are sorted out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements or enhancements to existing functionality link resolution About DocC's link resolution system
Projects
None yet
1 participant