Firefox source code analysis; lines of code per component - firefox

I am currently trying to analyse Bugzilla in order to find the ratio of number of bugs : lines of code for each Firefox component. However, I have never worked with Bugzilla before and have no knowledge of Firefox's codebase.
How would I go about finding lines of code per Firefox component (as they appear on Bugzilla under Comp header)? I have made an attempt at looking through mozilla central, but have no idea which source files relate to which components.
EDIT: Dexter pointed out that there is a directive BUG_COMPONENT in the mozilla-central tree, but this directive seems extremely incomplete and is not helpful. Any other advice, or pointers as to where I could get such advice would be much appreciated.

Great question! We recently added the BUG_COMPONENT directive (see the meta bug) to the Firefox code: it's in the moz.build file contained in each directory in the source. This directive allows linking each file in the repository to the related Bugzilla component.
For example, the following directive found here, tells that all the files in test/browser containing the Telemetry word belong to the Toolkit::Telemetry component on Bugzilla.
with Files("test/browser/*Telemetry*"):
BUG_COMPONENT = ("Toolkit", "Telemetry")
You can use either DXR or searchfox to quickly search the Firefox repository.
Updated the answer to account for the questions in the comments.
As noted in the comments, some components are tracked on Bugzilla (e.g. Activity Stream) but do not have a direct mapping to source files within the mozilla-central repository (the one Firefox is built from). That's because some newer components do not ride "the trains" (~6 weeks development cycle), but are rather updated more frequently and deployed as addons.
The code for these components usually lives under the Mozilla github account, along with other project. Since there are quite a number of projects, one way to identify the ones you might be interested in is to restrict them to JavaScript ones. If you follow this last link, you'll see the repository for both the test-pilot and Activity Stream (plus other addons).
I'm afraid the only way to match GitHub projects to Bugzilla components is to look at the name of the repository on GitHub and find the matching component in Bugzilla: you can type the name here to get some component suggestions. If you want to get fancy, you might also leverage the Bugzilla REST API:
Get a list of the JS GitHub project.
Extract the name of the project.
Use the REST API to get the component suggestion.
I would personally just consider the mozilla-central repository as a starting point, as it is mostly annotated: scrape the BUG_COMPONENT from the source files, map them to the paths then use the REST API to get the list of bugs.
Sidenote: the Download Panel seems to be correctly annotated in the main repo.

Related

How to successfully integrate API documentation into your build process

We've been looking into solutions to keep our API documentation accurate and up-to-date. This has led me down this rabbit hole of various solutions using standards such as OpenAPI and a whole universe of open source tools for integrating API documentation into your build pipeline, setting up mock servers, failing the build when APIs change or no longer match the documentation, etc. Right now, I'm fairly overwhelmed so to avoid having this question closed as "Too Broad", I'd like to narrow things down to a key piece of the puzzle that I'm a bit lost on. In simple terms, how do you connect the auto-generated Swagger JSON to the fully documented and detailed version of the spec (most likely as a bunch of YAML files and Markdown files)?
Right now, we have the ability to generate Swagger JSON based on our compiled code, but it's sparse and doesn't contain any information that can't be obtained through the code itself. Obviously I'd want to fill in details such as longer descriptions of each API, sample code, etc. From what I can tell, it's standard practice to generate your OpenAPI specs using a tool that can import directly from Swagger, then you use an editor (such as Swagger Editor) to fill in all the details. This gets bundled up as a bunch of YAML files, MD files, etc which get checked into Github, and then there's various tools that could build that into some portal for your users to go to (Redoc does this sort of thing).
However, how do changes to your original "auto-generated JSON" get merged into the "final product"? My guess would be there's some build step that runs some sort of diff tool that compares the autogenerated JSON from the current build to the "published" OpenAPI spec and then somehow alerts the team if there's new APIs that have to be documented or existing APIs that have changed and need their documentation update. Is this kinda on track or is there a big part I'm missing. Thanks!

Images in markdown files in GitHub Enterprise

I'm working on a README.md file in a GitHub Enterprise repository.
It's funny, I'm using the same code snippet I use in my public repositories, i.e.
![alt text](https://raw.github.com/repository/project/master/filename.png)
Unfortunately, this kind of command doesn't work on the enterprise project.
I see one big difference in the raw version of a picture. Specifically, in the enterprise repository I have a the URL of the raw picture file with a query parameter, e.g.
?token=AAABGqiVI6Qk6Mi4ZM0ZBeHrXexkUBmNks5W_AyCwA%3D%3D
Does someone know how to embed a picture in a markdown in GutHub enterprise?
Have you tried working with using relative links to your images? So trying to do something like ![](img/image_name.png)? The reason why I recommend this is because if they are working with your repo, they should have these images regardless and if they are accessing this online, GitHub will handle the rendering properly. This is assuming that you want this information to be facing towards others to be able to see it.
It is actually recommended by GitHub to not use absolute links such as [Absolute README link](https://github.com/username/repo/blob/branch/docs/more_words.md) Source
Edit: I also found this question/answer on SO that might be useful to refer to about how to solve it. It also mentions with the relative linking:
GitHub recommend that you use relative links with the ?raw=true parameter to ensure forked repos point correctly.
It also talks about how you can have a separate branch that can contain all of your screenshots and you can reference them as:
![Alt text](/../<branch name>/path/to/image.png?raw=true "Optional Title")
Hope this helps!

Project is missing in api (hence octo.exe can't find it)

We're using octo.exe to create releases. It starts suddenly giving error saying can't find project. I checked the api/projects and that's true, it is not in the returned json response. But when I look at the dashboard I can see the project. The only thing I did was cloning another project from this one earlier. The cloned project is working fine but not the original project.
It exists in dashboard (web gui) but not in api (hence octa.exe can't find project)
Looks like api is caching the projects. The new projects that I created via GUI not available in api.
Thanks,
I have had the same issue yesterday. It turns out to be something interesting. I believe that your project is still there properly set, but the total number of projects that you have become more than the listed ones in the API, and that's why the Octo.exe couldn't see it anymore.
I have explained here, how I managed to fix that issue quickly.
This is due to how pagination is implemented in Octopus (pretty poorly if you ask me). But you can override it. add this to the URL (at the end).
'?skip=0&take=2147483647'
alternatively, you can watch the json returned, if you find the links.Page.Next property you can use that link to get next page of the api response.

How to integrate Firefox Sync?

Firefox 4 comes soon (ok, next year ;)) and there is a Firefox plugin to sync your bookmarks etc. with Firefox 3.whatever .
I would like to know if anyone has a comprehensive, up-to-date tutorial to integrate Firefox Sync into your own plugin? Or any idea regarding this?
I mainly followed this official "tutorial" and also this blog post, but the information seems to be slightly outdated.
For example, the object is not called Weave anymore but Engines and the weave.engines. preference became services.sync.engines.. I played a little with all the mentioned options, but it does not seems to work (and my plugin does not show up in list where you can select what to sync).
I assume that the Tracker and Store classes are fine, the main problem is to register the engine...
The ClientAPI tutorial you mention is definitely the way to go. I updated it recently so if something's not working, please let us know so I can fix it in the docs. Wladimir's blogpost is definitely quite old and contains some outdated information. We will also make changes to some parts of the API in the upcoming beta releases, so be prepared for some flux...
The Weave namespace is still the canonical way to access Sync related APIs from UI code. It exposes components such as Weave.Service and Weave.Engines. You can import it via Components.utils.import("resource://services-sync/main.js"). If you want to implement your own engine, you'll have to import the actual underlying modules, though (all listed in the ClientAPI tutorial). The tutorial also describes how to register your custom engine implementation. Once it's registered, it won't automatically show up in the preferences UI, though. I suggest building your own UI that flips the services.sync.engine.YOURENGINE pref in your add-on's preferences.
Out of curiosity, what kind of data are you trying to sync?

What do I need to know to create Xcode project templates?

I know some of the tutorials for creating Xcode project templates, for example this one here: http://robnapier.net/blog/project-templates-364
This is the best one I could find. All others basically repeat the same info, or are no longer up to date, or worse tell me that even they don't know what they're doing. Possibly useful tools that are linked to here and in other places are no longer available.
I keep running into roadblocks, and would like to gather as much information as possible on the process of creating Xcode project templates. Info that is most importantly up to date (at least it must be relevant for Xcode 3 or higher).
For example, what I'd like to see is:
a description of the
TemplateChooser.plist and similar
plist files and what these options do
(in my case, once I add a
TemplateChooser.plist, my project
disappears from the Xcode project
template list)
how to create a project template that references another .xcodeproj (when I do that, the other .xcodeproj appears in the project template list even though it doesn't use the special naming convention)
processes that can be applied, for example is it possible to run a script during the creating of a project from a template? This would be useful to unzip certain files into the newly created project.
If you have the answer or suggestions to any of the issues above, I'd appreciate that. Otherwise any link to good Xcode project template resources would be highly recommended. Especially if there is an official documentation from Apple - I haven't found one yet which seems to imply that project templates are undocumented.
Have you seen these:
http://www.sodeso.nl/?p=895
http://www.codeproject.com/KB/iPhone/CreatingXcodeProject.aspx
If you say you have searched, I'm pretty sure you've already seen the links but these are the best resources I could find with my 'googlabilities'
You might try contact this guy - http://linkedin.com/in/mottishneor he has some related messages around the web
The links suggested by FX are also not bad at all!
There is indeed little XCode template info out there. What I have found of interest are the following links (I documented myself on the topic, but haven't yet gone any further):
a Google Code search reveals a few examples, but not much
in particular, I found interesting to look at the code provided by Three20; they have some basic examples, like here
referencing another project worked for me, so maybe you could open a specific question about that giving more details?
there is information scattered on the Apple mailing-lists
there is no official documentation from Apple, as is evidenced by the lack of results to this query
I'm sorry if this is not a Enlighting, concise answer. As you said, it's not well documented, and sources are all over the place. I just hope I could highlight some places to find information that your own searches might not have reached :)
I don't have a Mac anymore, so this is as much as I can give you without testing this myself. As far as I can tell, Xcode templates are undocumented by Apple.
This guy has some guides for messing with Xcode templates but the info is pretty sparse. My suggestion for working with templateChooser.plist is to try to only edit that file in the interface builder.
This guide is a good example of how to add a reference to another .xcodeproj. For the reason you were having trouble adding a reference to your project we probably need more information.
If you scroll way down in this doc you can that each template already includes a script called myscript.sh. This script will show up in the scripts menu for projects built with that template. That isn't quite as convenient as running scripts automatically, but it's better than nothing.
In conclusion, Xcode template documentation is a nightmare. It looks like there are a lot of powerful features there, but they are obscured because of lack of user friendlyness and because documentation lags far behind Apples updates of Xcode. It just doesn't seem to be a priority for them. I hope this helps.
And yet another video link http://howtomakeiphoneapps.com/2010/10/how-to-make-custom-xcode-templates-with-video/

Resources