Skip to content

Conversation

@sofiabordagorry
Copy link

What does this PR do?

Addresses issue #51 :

  • Adds has_docs field to HexpmVersion schema
  • Updates template to ensure version documentation links are only shown when both @package.docs_html_url and @version.has_docs are present
  • Updates tests to verify correct documentation link behavior and updates factory's hexpm_snapshot data to include docs_html_url (required since template also validates this field)

Before

Screen.Recording.2026-01-20.at.4.58.58.PM.mov

After

Screen.Recording.2026-01-20.at.4.59.42.PM.mov

Copy link
Collaborator

@grzuy grzuy left a comment

Choose a reason for hiding this comment

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

Niceee - thank you! 👏

embedded_schema do
field :version, :string
field :elixir_requirement, :string
field :has_docs, :boolean
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we already have hexpm version stored in the database embedded in the packages table, at least for the latest version?
I think other versions in the dropdown are fetched on demand.

If that's the case, what does this default for versions already stored? false?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for pointing this out!

Yes, hexpm_latest_stable_version_data is stored in the packages table. Other versions in the dropdown are indeed fetched on-demand as you mentioned. For existing records stored before this PR, since the has_docs field wasn't being saved, it won't exist in the JSON. When Ecto loads these records, the field will be nil.

I'm considering two approaches to handle this. My first thought was doing a migration and reset all hexpm_latest_stable_version_data to nil to force a refetch with has_docs included. My other option was to update the condition in package_live.html.heex

@package.docs_html_url && @version.has_docs

to:

@package.docs_html_url && (@version.has_docs != false)

This treats nil (existing records) as true, maintaining current behavior where we show documentation links by default. Versions fetched on-demand (from the dropdown) will correctly show "No documentation" when has_docs is explicitly false, which from what I've seen mostly applies to older versions rather than the latest one. Also if there's a new latest version then the version in the database will be updated, including the has_docs field.

Let me know what you think of these or if you have any suggestion :)

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.

2 participants