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

documentation error: pages not list of page objects, but of file objects #1736

Closed
rkoe opened this issue Feb 3, 2019 · 4 comments · Fixed by #2361
Closed

documentation error: pages not list of page objects, but of file objects #1736

rkoe opened this issue Feb 3, 2019 · 4 comments · Fixed by #2361

Comments

@rkoe
Copy link

rkoe commented Feb 3, 2019

The documentation about "pages" on https://www.mkdocs.org/user-guide/custom-themes/ is wrong.
It says:

pages
A list of page objects including all pages in the project.

But in reality, pages is a list of file-objects, which also contain the page objects.
The page-object can be accessed by pages[i].page.

@waylan
Copy link
Member

waylan commented Feb 3, 2019

The documentation is correct in that it describes the expected behavior. If the pages template variable does not actually contain what is described, then that is a bug. Thanks for the report.

@fhiegel
Copy link

fhiegel commented Feb 24, 2021

It seems that "pages" are file-object. I tried to use the "pages" collection on my project :

Using pages as page-objects :

<h3>Pages</h3>
<ul>
  {% for item in pages %}
  <li>{{ item.title }}</li>
  {% endfor %}
</ul>

Output :
image

Using pages as file-objects :

<h3>Pages</h3>
<ul>
  {% for item in pages %}
  <li>{{ item.page.title }}</li>
  {% endfor %}
</ul>

Output :
image

Using MkDocs on windows with "serve" command with version :

mkdocs, version 1.1.2 from [...]\Python39\site-packages\mkdocs (Python 3.9)

@waylan
Copy link
Member

waylan commented Feb 25, 2021

After reviewing the code, yes the documentation is wrong. There is no "pages" collection. It seems the variable name was poorly chosen. Perhaps we should alias it as files. Also, it appears that we don't actually document File objects, which we should do.

@waylan
Copy link
Member

waylan commented Apr 10, 2021

Took another look at this. The name pages is correct as the list only contains File objects for pages. Other types of files are not included. However, the documentation is misleading.

waylan added a commit to waylan/mkdocs that referenced this issue Apr 10, 2021
waylan added a commit that referenced this issue Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants