Skip to content
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

Documented classes missing from generated class_list.html but present in generated alphabetical index. #1518

Open
mcorino opened this issue Nov 7, 2023 · 0 comments

Comments

@mcorino
Copy link

mcorino commented Nov 7, 2023

I noticed today that several (17) classes (of a total of 749) were missing from the generated class_list.html while they were present in the generated alphabetical index as well as having a proper class .html generated which was also properly crosslinked.
One class is my 'Wx::App' where 'Wx' is the topmost namespace of the library.

Looking through the code and doing some debugging I found that at the point of the classlist method in 'templates/default/fulldoc/html/setup.rb' the object instance from Registry.root representing the topmost 'Wx' module did not have an instance
for the 'Wx::App' class in its #children list.
That instance was however present when looked up with Registry.at('Wx::App') and the #namespace instance object of that object DID have an instance for 'Wx::App' in its #children list.
Comparing the object_id-s of the 'Wx' instance included in Registry.root and the #namespace instance showed these were different objects and both were NOT proxies but fully resolved objects which I had not expected to be the case.

The debug output from yardoc does not show any errors or other noticable messages.

I have a workaround by loading a template customization for 'templates/default/fulldoc/html/setup.rb' which contains this code:

# frozen_string_literal: true

def init
  # It seems YARD messes things up so that a number of classes are not properly
  # registered in their enclosing namespaces.
  # This hack makes sure that if that is the case we fix that here.
  all_classes = Registry.all(:class)
  all_classes.each do |c|
    if (ns = c.namespace)
      unless ns.children.any? { |nsc| nsc.path == c.path }
        ns.children << c # class missing from child list of enclosing namespace -> add here
      end
    end
    if (ns = Registry[c.namespace.path])
      unless ns.children.any? { |nsc| nsc.path == c.path }
        ns.children << c # class missing from child list of enclosing namespace -> add here
      end
    end
  end
  super
end

I don't think the first if ... end block is really necessary but the second definitely is.

This currently solves the problem for me but I do not much like having to maintain this horrible hack.

Does anyone have an idea what is causing this problem?

Steps to reproduce

I cannot reproduce with a minimal sample. Seems to be somehow related to larger, more complex documenting setups.
The project I am generating for is https://github.com/mcorino/wxRuby3.

Actual Output

Documented classes missing from generated class_list.html

Expected Output

A generated class_list.html including all documented classes.

Environment details:

  • OS: OpenSuSE 15.5
  • Ruby version (ruby -v): 3.2.0
  • YARD version (yard -v): 0.9.34

I have read the Contributing Guide.

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

No branches or pull requests

1 participant