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

feature: full class source #142

Closed
samvanstroud opened this issue Mar 25, 2024 · 2 comments
Closed

feature: full class source #142

samvanstroud opened this issue Mar 25, 2024 · 2 comments
Assignees
Labels
feature New feature or request

Comments

@samvanstroud
Copy link

It would be great to have the option to show the full source code for a class.
This would be useful especially when not explicitly displaying the members (where it is possible to show the source for each member method)

@pawamoy
Copy link
Member

pawamoy commented Mar 25, 2024

I guess you are using merge_init_into_class: true, because without it, the code for the whole class is shown 🙂

You can achieve this anyway by overriding the source block in the class.html template:

{% extends "_base/class.html" %}

{% block source scoped %}
<details class="quote">
  <summary>Source code in <code>
    {%- if class.relative_filepath.is_absolute() -%}
      {{ class.relative_package_filepath }}
    {%- else -%}
      {{ class.relative_filepath }}
    {%- endif -%}
  </code></summary>
  {{ class.source|highlight(language="python", linestart=class.lineno, linenums=True) }}
</details>
{% endblock source %}

Let me know if that works for you!

@pawamoy pawamoy added the feature New feature or request label Apr 13, 2024
@samvanstroud
Copy link
Author

Thank you - this is perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants