Documentation date

89 views
Skip to first unread message

Carlos Ochoa Gómez

unread,
Jul 16, 2020, 3:40:33 AM7/16/20
to sphinx-users
Good Morning. I need to put the modification date of the rst documents that I generate at the beginning of it or anywhere. I put it with the date function but it does not work because it gives the date of the entire project where I have many rst files

Matthias Geier

unread,
Jul 16, 2020, 4:34:12 AM7/16/20
to sphinx...@googlegroups.com
> Good Morning. I need to put the modification date of the rst documents that I generate at the beginning of it or anywhere. I put it with the date function but it does not work because it gives the date of the entire project where I have many rst files

If you are using Git, you can try my Sphinx extension
https://github.com/mgeier/sphinx-last-updated-by-git.

cheers,
Matthias

>
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/8fde7216-04d5-47c5-ac15-8589eae5b1bbo%40googlegroups.com.

carlos...@gmail.com

unread,
Jul 16, 2020, 4:36:24 AM7/16/20
to sphinx-users
Ok i look at it thanks
Message has been deleted

Carlos Ochoa Gómez

unread,
Jul 18, 2020, 2:09:41 PM7/18/20
to sphinx-users
Dear sir, your extension is fine but I find it very complicated for what I want. I will continue looking for something simpler. Regards

Matthias Geier

unread,
Jul 19, 2020, 3:55:33 AM7/19/20
to sphinx...@googlegroups.com
On Sat, Jul 18, 2020 at 8:09 PM Carlos Ochoa Gómez wrote:
>
> Dear sir, your extension is fine but I find it very complicated for what I want. I will continue looking for something simpler. Regards

Thanks for trying it out!

Can you please tell me what exactly was too complicated?
Maybe I can improve the extension?

Ideally, it shouldn't be "very complicated", it should actually be
very simple, only three steps:

1. Install the Python package sphinx-last-updated-by-git
2. Add 'sphinx_last_updated_by_git' to extensions in your conf.py
3. Run Sphinx!

That's literally the minimum you have to do to use any Sphinx extension at all.

Did something not work as expected?

cheers,
Matthias

Carlos Ochoa Gómez

unread,
Jul 19, 2020, 4:04:45 AM7/19/20
to sphinx...@googlegroups.com
That's ok thanks 

CARLOS OCHOA GÓMEZ
Técnico Autónomo Informático
Enviado desde mi smartphone
Tfno: 679189284

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.

Carlos Ochoa Gómez

unread,
Jul 19, 2020, 4:07:55 AM7/19/20
to sphinx...@googlegroups.com
I need that but be able to put the date in one position. In other words, having control over the date.

Regards


CARLOS OCHOA GÓMEZ
Técnico Autónomo Informático
Enviado desde mi smartphone
Tfno: 679189284

Matthias Geier

unread,
Jul 19, 2020, 4:56:07 AM7/19/20
to sphinx...@googlegroups.com
On Sun, Jul 19, 2020 at 10:07 AM Carlos Ochoa Gómez wrote:
>
> I need that but be able to put the date in one position. In other words, having control over the date.

That's indeed not that simple ...

But you can probably do what you want with a custom HTML template.

The sphinx_last_updated_by_git extension modifies the "last_updated"
variable, see https://www.sphinx-doc.org/en/master/templating.html#last_updated.

In your custom HTML template, you can then use this:

{{ last_updated }}

cheers,
Matthias
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/CABQSU1viRHrRjQ8dpAUc6%3De-0%3DE8AKRb8yHVojmT_C08m5SKcQ%40mail.gmail.com.

Carlos Ochoa Gómez

unread,
Jul 21, 2020, 12:49:15 PM7/21/20
to sphinx-users
Dear Mr. I have been testing your solution and the template but it doesn't work for me. I want to see in each rst file the last modification date. If you can explain more I would appreciate it

Thanks

Matthias Geier

unread,
Jul 21, 2020, 1:55:28 PM7/21/20
to sphinx...@googlegroups.com
> Dear Mr. I have been testing your solution and the template but it doesn't work for me. I want to see in each rst file the last modification date. If you can explain more I would appreciate it

Sure, here is a little example:

* make sure the sphinx-last-updated-by-git package is installed (e.g. with pip)

* add this to your conf.py:


extensions = [
'sphinx_last_updated_by_git',
]
templates_path = ['_templates']


* create a directory named _templates in your source directory (where
conf.py lives)

* inside this new _templates directory, create a file named page.html
(so the path is _templates/page.html) with the following content:


{% extends "!page.html" %}
{% block body %}
<div class="my-date">
This page was last updated on {{ last_updated }},
have fun reading it!
</div>
{{ super() }}
{% endblock %}


* run Sphinx

This should insert a sentence with the "last updated" date at the top
of each page.
If you want it to appear at the bottom, just insert the text below the
"super()" line.

You can of course use arbitrary HTML and CSS to make it look however you like.

If you want to change the date format, you can use the
html_last_updated_fmt setting
(https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_last_updated_fmt).

I hope this helps!

cheers,
Matthias

Carlos Ochoa Gómez

unread,
Jul 21, 2020, 1:59:18 PM7/21/20
to sphinx-users
Thank you very much I will review because I was doing something similar. I try it and tell you something

carlos...@gmail.com

unread,
Jul 22, 2020, 12:30:40 PM7/22/20
to sphinx-users
I have been able to test it and it works fine. Thank you very much,

Daniel Scott

unread,
Nov 25, 2020, 10:37:28 PM11/25/20
to sphinx...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.

Nazia Sarfraz

unread,
Mar 12, 2021, 4:03:48 PM3/12/21
to sphinx-users
Nazona offering IT Solutions, Consultancy, B-B Project, Solutions of Cloud Development & support, Virtualization, IT Help Desk Services, Network & Server Support, Digital Marketing Services, SEO, Graphics Designing and all type of IT or non-IT projects.
Contact Us: nazo...@gmail.com
nazona all services-1--fb cover pic.jpg
Reply all
Reply to author
Forward
0 new messages