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

modules: Add an 'hotdoc' module #4016

Merged
merged 5 commits into from
Aug 29, 2018
Merged

Conversation

thiblahute
Copy link
Contributor

@ignatenkobrain
Copy link
Member

Flake8 detected 6 issues on b4597d0
Visit https://sider.review/gh/19784232/pull_requests/4016 to review the issues.

from hotdoc.run_hotdoc import run
except Exception as e:
raise MesonException('hotdoc %s required but not found. (%s)' % (
MIN_HOTDOC_VERSION, d))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

[F821] undefined name 'd'

return value

return os.path.relpath(os.path.join(state.environment.get_source_dir(), value),
state.environment.get_build_dir())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

[E128] continuation line under-indented for visual indent

raise MesonException('hotdoc executable not found')

try:
from hotdoc.run_hotdoc import run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

[F401] 'hotdoc.run_hotdoc.run' imported but unused

' required for the project name.')

project_name = args[0]
def file_to_path(value):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

[E306] expected 1 blank line before a nested definition, found 0



def initialize(interpreter):
return HotDocModule(interpreter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

[W292] no newline at end of file

@thiblahute
Copy link
Contributor Author

@jpakkane Could you please rebuild your CI docker image with the changes from that PR ?

@@ -0,0 +1,9 @@
project('hotdoc', 'c')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably specify a version here, then use meson.project_version() in generate_doc()

Copy link
Contributor Author

@thiblahute thiblahute Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want that to be automatic if project_version is not specified?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good idea, but it might lead to confusing bugs in practice, as most projects would want to use the major version here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jpakkane
Copy link
Member

I have started a rebuild of the CI image. It should be uploaded in about an hour. In the future please don't fiddle with the travis files, but change the master Dockerfile under ciimage instead.

@thiblahute thiblahute force-pushed the hotdoc branch 4 times, most recently from 705724b to 5b73a0d Compare August 15, 2018 15:35
@@ -0,0 +1,317 @@
import os
import subprocess
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

[F401] 'subprocess' imported but unused

@thiblahute
Copy link
Contributor Author

The AppVeyor failure looks weird and is totally unrelated I believe.

Copy link
Contributor

@MathieuDuponchelle MathieuDuponchelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This otherwise looks ok to me, good job :)

MIN_HOTDOC_VERSION = '0.8.100'


class HotdocTargetBuilder:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, this builder object is simply used to hold intermediary state while processing the arguments, which is why it's separate from the actual target classes, and why you don't simply have a huge function in the module to prepare the targets. That makes sense to me, but I would suggest following that approach to its end, and simply have something like:

builder = Builder()
targets = builder.make_targets()

in the generate_doc() method of the module, makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I started having a generic Builder that could be reused in other modules, but that experiment didn't work well, let do what you suggest, it will be cleaner :-)

@MathieuDuponchelle
Copy link
Contributor

@thiblahute , you will also need to add documentation, and a release snippet

The module might need to add extra methods on the returned targets
and thus it can return TargetHolders, we should process the
held targets
@thiblahute
Copy link
Contributor Author

Added documentation and made the small refactoring @MathieuDuponchelle asked for.

@MathieuDuponchelle
Copy link
Contributor

We obviously will need @jpakkane 's approval, but this looks good to go to me now :)

@jpakkane
Copy link
Member

The sources argument seems to only handle strings. Should it work with files objects as well? I would imagine people wanting to do something like:

sources = files(...)
shared_library('something', sources)
hotdoc.generate_doc(...
  c_sources : files,
  ...
  )

To only have to list the files once?

@thiblahute
Copy link
Contributor Author

Thanks :-)

@marc-h38
Copy link
Contributor

marc-h38 commented Feb 21, 2020

Hi Thibault. It's not very intuitive to have to invoke ninja upload to merely rebuild the documentation (and not upload anything).

It's also strange that a bare ninja builds the documentation but only after a ninja clean... and without colored output?!? Weird.

I'd like to make this better but right now I'm completely lost in these inconsistencies. Care to shed some light?

PS: all the above observed with today's master branch at commit be9bff8

@thiblahute
Copy link
Contributor Author

It's not very intuitive to have to invoke ninja upload to merely rebuild the documentation (and not upload anything).

ninja upload? Never heard of that! :-)

It's also strange that a bare ninja builds the documentation but only after a ninja clean... and without colored output?!? Weird.

It doesn't build the doc by default unless you specify it when you declare the target, it is build only when installing or when invoking the ninja targetname-doc.

@marc-h38
Copy link
Contributor

Hi Thibault, I think I figured out why we were talking across each other. I should have written that I'm very specifically referring to building the documentation of meson itself and your commit 6f72473b2457ecd4, and especially this line of yours:

ninja -C build/ upload

@thiblahute
Copy link
Contributor Author

Hi Thibault, I think I figured out why we were talking across each other. I should have written that I'm very specifically referring to building the documentation of meson itself and your commit 6f72473, and especially this line of yours:

ninja -C build/ upload

Ah, I just ported previous doc there (where it was explaining how to upload the doc), you can just run ninja -C build/ in there as the hotdoc target is build_by_default: true

@marc-h38
Copy link
Contributor

ninja -C build works but only the first time. ninja -C build upload seems to rebuild every time; while not ideal it's much better.

$ touch markdown/*
$ ninja -C build/
ninja: Entering directory `build/'
ninja: no work to do.
$ ninja -C build/ upload
ninja: Entering directory `build/'
[0/1] Running external command upload.
WARNING: [core]: (markdown-bad-link): ...

@MathieuDuponchelle
Copy link
Contributor

ninja -C build clean && ninja -C build, while not ideal, should do the trick. hotdoc has support for generating deps files:

  --deps-file-dest DEPS_FILE_DEST
                        Where to output the dependencies file
  --deps-file-target DEPS_FILE_TARGET
                        Name of the dependencies target

but I don't think this is used by the hotdoc module.

@thiblahute
Copy link
Contributor Author

but I don't think this is used by the hotdoc module.

It does and it worked at some point, we should check why it doesn't anymore.

@MathieuDuponchelle
Copy link
Contributor

Oh, good to know, then yeah that would be the thing to check first :)

@xclaesse
Copy link
Member

@MathieuDuponchelle @thiblahute : While you're here, would you guys agree to add yourself in CODEOWNERS for the hotdoc module?

@thiblahute
Copy link
Contributor Author

@MathieuDuponchelle @thiblahute : While you're here, would you guys agree to add yourself in CODEOWNERS for the hotdoc module?

I guess I am fine with that, what does it involve in practice?

@xclaesse
Copy link
Member

You get requested review automatically for any PR that touch that module. More generally, you are the maintainer of that module, you take the decisions about new features, etc that gets included. I've been pushing to delegate more responsibilities in the Meson project: #6485.

@thiblahute
Copy link
Contributor Author

I am fine with that.

@MathieuDuponchelle
Copy link
Contributor

that is a good idea yes :) thib knows more about the module than I do however

@marc-h38
Copy link
Contributor

ninja -C build clean && ninja -C build, while not ideal

While I have admittedly no idea why it works, ninja -C build upload seems to do the same, is shorter to type and is what @koponomarenko documented in meson/docs/README.md (PR #4275 commit e53be9c - before CODEOWNERS I guess :-)

hotdoc has support for generating deps files:

Depending on the complexity this may be overkill for meson/docs/ which take less than 2 seconds to generate.

@MathieuDuponchelle
Copy link
Contributor

While I have admittedly no idea why it works, ninja -C build upload seems to do the same

Sure, but if the goal is to simply rebuild the local copy, then there's not much point in trying to upload to a place where you probably don't have write access :D

Depending on the complexity this may be overkill for meson/docs/ which take less than 2 seconds to generate.

Right, but meson needs some trigger to make it rebuild when some dep has changed doesn't it?

@marc-h38
Copy link
Contributor

then there's not much point in trying to upload to a place where you probably don't have write access :D

Let me quote the very first sentence I used to start this recent discussion:

Hi Thibault. It's not very intuitive to have to invoke ninja upload to merely rebuild the documentation (and not upload anything).

Back to you:

Right, but meson needs some trigger to make it rebuild when some dep has changed doesn't it?

I meant: no, in this very particular case it could just rebuild every time because it's quick. Like ninja upload already does (how?) for some unknown reason.

@MathieuDuponchelle
Copy link
Contributor

Let me quote the very first sentence I used to start this recent discussion:

Hi Thibault. It's not very intuitive to have to invoke ninja upload to merely rebuild the documentation (and not upload anything).

Yes? My point is that ninja upload isn't the correct command to use to rebuild the doc locally, I gave you the correct one and you replied something about conciseness, I don't really get your point now

I meant: no, in this very particular case it could just rebuild every time because it's quick. Like ninja upload already does (how?) for some unknown reason.

ninja upload presumably uses hotdoc's uploading feature, and hotdoc always rebuilds when called. Re rebuilding every time, that's hardly the desirable outcome, a well-behaved project should do nothing on the second of two successive calls to ninja -C build, I'm sure we can agree on that. Repeating what I said earlier, we should look into why the depsfile setup is broken, it's probably not very difficult to fix.

@thiblahute
Copy link
Contributor Author

OK, here is the fix in meson: hotdoc/hotdoc#184

Although I add this issue with ninja 1.9 which is fixed in ninja 1.10.

@marc-h38
Copy link
Contributor

marc-h38 commented Feb 27, 2020

My point is that ninja upload isn't the correct command to use to rebuild the doc locally, I gave you the correct one and you replied something about conciseness, I don't really get your point now

Involving ninja clean; ninja every time is neither convenient nor the "correct" way to build anything.

I will try the fix, thanks Thibault.

@MathieuDuponchelle
Copy link
Contributor

Involving ninja clean; ninja every time is neither convenient nor the "correct" way to build anything.

It's the correct way if you want to rebuild from scratch, using the upload target as a workaround clearly isn't, anyway this argument is pointless

@marc-h38
Copy link
Contributor

It [ninja clean] is the correct way if you want to rebuild from scratch,

Agreed, keeping in mind rebuilding from scratch is a workaround in the first place.

Unless changes are made to the meson.build or related files themselves and then ninja clean is regularly not enough - I wasted way too much time trusting ninja clean in that case so I simply stopped using it when editing meson.build. rm -rf build or git clean -fdx are then the only way. Example: https://github.com/zephyrproject-rtos/zephyr/blob/master/cmake/pristine.cmake

See also "meson + ninja wrapper script" comment here: #6434 (comment)

tl;dr: using ninja clean is always the sign something somewhere is wrong.

anyway this argument is pointless

Agreed, as in: " is bad better than very bad?"

@MathieuDuponchelle
Copy link
Contributor

" is bad better than very bad?"

Good news is with thib's fix the behaviour is correct again so we can forget about the argument :D

@eli-schwartz
Copy link
Member

Unless changes are made to the meson.build or related files themselves and then ninja clean is regularly not enough - I wasted way too much time trusting ninja clean in that case so I simply stopped using it when editing meson.build. rm -rf build or git clean -fdx are then the only way.

If meson's builtin support for reconfiguring on changes to meson.build isn't enough for you (why not???) then I would recommend using meson setup --wipe build/ instead, which should be the same as rm -rf build/ except it preserves the command line you previously used. ;)

@marc-h38
Copy link
Contributor

Good news is with thib's fix the behaviour is correct again

I thought I was trying the fix yesterday but realized at last the fix is in hotdoc itself and not in the meson module and that the fixed hotdoc version isn't released in pip yet :-/ Will try again another time.

If meson's builtin support for reconfiguring on changes to meson.build isn't enough for you (why not???)

It is enough... most but not all the time. When changing cross files maybe? I'm actually amazed it is enough most of the time, however my project is small enough that it's just faster to rm -rf build/ and not think about edge cases.

I would recommend using meson setup --wipe build/ instead

I tried --wipe and I'd love to use it, however it fails when build/ doesn't exist so rm -rf build is just simpler to script. Already reported in #6434 (comment)

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

Successfully merging this pull request may close these issues.

7 participants