-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add sphinx defaults for cookiecutter'd project #2555
Conversation
|
||
3. Run the following command: :: | ||
|
||
$ sphinx-apidoc -f -o ./docs/modules/ ./tpub/ migrations/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sphinx autodoc is cool, but apidoc seems less useful. So it's there but I don't talk about it.
SOURCEDIR = . | ||
BUILDDIR = _build | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build -c . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-c .
flag used because conf.py
is in different location from source files
"""Default user for {{cookiecutter.project_name}}. | ||
""" | ||
|
||
# First Name and Last Name do not cover name patterns | ||
# around the globe. | ||
#: First and last name do not cover name patterns around the globe | ||
name = CharField(_("Name of User"), blank=True, max_length=255) | ||
|
||
def get_absolute_url(self): | ||
"""Get url for user's detail view. | ||
|
||
Returns: | ||
str: URL for user detail. | ||
|
||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use google style docstring, picked up by apidoc, as an example.
The comments aren't that illuminating, but it shows how this works.
09b6601
to
758d66e
Compare
The diff is now showing the things which have been merged recently, something probably gone wrong in a rebase. Could you try tidying this up? I don't mind merge commits, and they are usually safer, now it's a bit tricky to review. |
Yes, I was rebasing as I made some fixes but my commit got buried. I'll drop the non-PR commits. |
-serve, watch + live reload for docs + code file changes -update project makefile + make.bat -separate _source and _build -add packages and paths to use autodoc -edit/add documentation with examples (both at django-cookiecutter and inside generated project) -add formatted comments in User model for pickup by Sphinx apidoc -serve docs from a separate docs container for docker build
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
@$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Sphinx only recognizes the -M option if it is placed first."
Include as helper comment only
I wish I had used type hints instead of the older style docstrings, but I'd rather just get this closed and (hopefully) come back later than start making more edits. |
Whoops! I accidentally closed this instead of hitting "comment"! |
Happens to the best of us, no worries 😄 |
I made a "resolve conflicts" that introduced a typo, hence failing tests. Is there anything else I should do to get this ready to merge? |
Not really at this point. I need to find a bit of time to sit down and review this in properly. Don't worry too much about the conflicts for now, let's do it just before merging (I can do it if needed). |
&& apt-get install -y texlive-fonts-recommended \ | ||
&& apt-get install -y texlive-latex-extra \ | ||
&& apt-get install -y latexmk \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need these if we don't use latex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was decided to drop it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: I just removed this in an additional fixup commit. Do you prefer I squash those? Does it matter?
I commented line 14 -- I meant to comment out lines 14-17 with the note on line 13.
I've seen little notes like that in the project elsewhere.
Should I just delete instead?
I'll fix it in either direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry about squashing, we can do it at merge time.
I don't mind either way, really. I don't use latex anymore, so I'd be in favour of removing them, but that's subjective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @hanhanhan question was whether to keep the lines but comment them out. Personally, I rather delete lines then comment them because, well - that's what git is for! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Git history won't be preserved into projects that will be generated, only in the template code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - didn't think it from that perspective. This is super helpful PR and I tried out on a demo project recently and I can report that it worked fine with few custom modifications I need for my local docker setup (not relevant to the project).
Thanks a lot @hanhanhan !
sounds good! Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
# Conflicts: # {{cookiecutter.project_slug}}/requirements/local.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave it a final look, and it looks good.
Description
Add sphinx defaults for cookiecutter'd project
Rationale
Setting up sphinx documentation is fiddly (and often low priority).
How about a setup that works well from the start?
If it's easier to document as you go, it's more likely to happen.
Use case(s) / visualization(s)
Try:
locally in the docs folder, or in the docs container.
Navigate to port 7000 on your localhost/host (this is in the django-cookiecutter docs now too).
Considerations
TheI tested the make.bat filemake.bat
file needs testing. I will.